[英]How can I prevent the Internet Explorer Info Bar from appearing when a user downloads a file?
[英]Is this an optimal way to prevent the IE8 security banner from appearing when the user downloads a file?
我將iframe的src屬性設置為下載網址,然后使用appendChild將iframe添加到頁面的主體以觸發下載。 如果下載的網址是完全限定的網址,即“ http://example.abc.com/download/”,則下載將觸發安全欄。 如果url為“ http:// example / download /”,則下載將沒有安全欄。
有人可以解釋這種情況如何以及為什么發生嗎? 我了解到,當頁面嘗試從不同於頁面url的url下載文件時,IE8會拋出安全提示,但是我認為這不會很挑剔。 另外,當前頁面的網址是完全合格的,因此我認為獲取的結果將被顛倒。
僅切掉整個域的一部分以避免出現安全旗標,這是一個很好的解決方案嗎?
避免安全警告的最簡單方法是在新窗口而不是<iframe>
打開下載URL。
例如:
<a href='//www.example.com/your_download' onclick='init_download(this.href);return false' target='_blank'>Test</a>
function init_download(link) {
window.open(link, '_blank', 'toolbar=0,location=no,directories=0,status=0,scrollbars=0,resizeable=0,width=1,height=1,top=0,left=0');
window.focus();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.