簡體   English   中英

Javascript文件下載不適用於IE6和IE7

[英]Javascript file download not working on IE6 and IE7

我有以下代碼

Response.TransmitFile(filePath);

使用以下代碼打開新窗口

this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Download", string.Format("window.open('{0}', target = 'new');", downloadURL), true);

該功能適用​​於IE8,但不適用於IE6和IE7

anyidea這里可能出什么問題了?

您很可能會收到腳本錯誤

this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Download", string.Format("window.open('{0}', target = 'new');", "http://example.com"), true);

應該呈現javascript:

window.open('http://example.com', target = 'new');

在上面的腳本中,目標變量未定義。 如果您希望鏈接在新窗口中打開,請嘗試:

this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Download", string.Format("window.open('{0}', '_blank');", downloadURL), true);

在此處查找window.open函數可用參數的列表。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM