簡體   English   中英

從asp.net打開靜態HTML文件

[英]Open static HTML file from asp.net

我需要使用以下JavaScript從aspx頁面打開HTML頁面,但它在chrome和firefox中顯示空白頁面,而IE9中什么也沒有發生。

 ClientScript.RegisterStartupScript(this.GetType(), "openWindow",
 "<script language='javascript' type='text/javascript'>showModalDialog('C:/Users/Administrator/Desktop/test.html');</script>");

您嘗試在客戶端計算機上打開文件

C:/Users/Administrator/Desktop/test.html

您必須區分在服務器上運行的代碼和在客戶端上運行的代碼。

制作html頁面,網頁時,您的文件和連接必須使用http://協議從服務器獲取。 這樣就無法從服務器讀取文件,也無法向客戶端發出命令從其計算機讀取文件的命令。

你可以試試這個

string strScript = "window.open('C:/Users/Administrator/Desktop/test.html');";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), strScript, true);

暫無
暫無

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

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