简体   繁体   English

从asp.net打开静态HTML文件

[英]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. 我需要使用以下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>");

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. 制作html页面,网页时,您的文件和连接必须使用http://协议从服务器获取。 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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