简体   繁体   English

Vb.net Webbrowser总是在显示javascript时下载文件

[英]Vb.net webbrowser always downloads file when showing javascript

i'm making a simple app that asks a remote server via webbrowser, but, if the remote page is replying with javascript, instead of showing the text the browser always prompt to download the search.js file. 我正在制作一个简单的应用程序,该应用程序通过webbrowser询问远程服务器,但是,如果远程页面正在使用javascript进行回复,则浏览器始终会提示您下载search.js文件,而不是显示文本。 is there a way to only show the source instead of downloading the file ? 有没有一种方法只显示源文件而不下载文件?

Downloading the .js file is the default behavior of IE(which is used by the webbrowser control. If you want to display the source, you could download the the file and set DocumentText to display the source. 下载.js文件是IE(Webbrowser控件使用的默认行为)。如果要显示源,可以下载该文件并设置DocumentText以显示源。

I'm not sure if this is the best way to do this by this should work 我不确定这是否是最好的方法

WebClient client = new WebClient();    
var source = client.DownloadString("http://example.com/somescript.js");

webBrowser1.DocumentText = source;

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

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