0

我想在我的 C# 浏览器中显示 javascript 代码。通常,当我导航时,浏览器想要保存它..但我希望浏览器在浏览器的屏幕上显示它..我认为我必须用 webbrowser 做一个 javascript 查看器..

我用过那个代码,但它不起作用(仍然要求保存..)

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

1 回答 1

2

Don't use a WebBrowser control for this but simply download it using a HttpClient and display it e.g. in a 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).

于 2012-06-06T13:36:46.180 回答