简体   繁体   English

如何在WebBrowser中显示Javascript代码?

[英]How can I show Javascript code in WebBrowser?

I want to show javascript code in my webbrowsers in C#. 我想在C#中的webbrowsers中显示javascript代码。 Normally, When I navigated, browser wants to save it.. But I want browser shows it on browser's screen.. I think that I must do a javascript viewer with webbrowser.. 通常,当我导航时,浏览器想要保存它..但我希望浏览器在浏览器的屏幕上显示它...我认为我必须使用webbrowser进行javascript查看器..

I used like that code but it doesnt work (still asking to save..) 我喜欢那些代码,但它不起作用(仍然要求保存..)

webBrowser1.Navigate("http://xxxx.com/aaa.js", "_mainframe");

Don't use a WebBrowser control for this but simply download it using a HttpClient and display it eg in a TextBox. 不要为此使用WebBrowser控件,而只需使用HttpClient下载它并将其显示在TextBox中。

The WebBrowser control is basically an embedded IE which will download files if it thinks a file with that MIME type should be downloaded or if there are headers like Content-disposition: attachment (which force a download prompt in the browser). WebBrowser控件基本上是一个嵌入式IE,如果它认为应该下载具有该MIME类型的文件,或者如果存在Content-disposition: attachment (在浏览器中强制下载提示)等标题,则会下载文件。

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

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