简体   繁体   中英

Open static HTML file from asp.net

I need to open HTML page from my aspx page using following javascript, but it's showing blank page in chrome and firefox and nothing happen in IE9.

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

You try to open a file on the client computer

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

you must distinguish the code that run on server and the code that run on client.

When you make an html page, a web page, your files and connections must get from the server using http:// protocol. Its impossible to read a file that way from the server, its also impossible to give command to the client to read a file from his computer.

you can try this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM