如何在C#中使用Web浏览器控件运行javascript网站? [英] How to run a javascript website on web browser control in C#?
本文介绍了如何在C#中使用Web浏览器控件运行javascript网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在C#中使用Web浏览器控件从Internet加载网页。它工作得非常好,直到我运行javascript网页。我怎么想解决这个问题?
解决方案
我在C#中使用Web浏览器控件来加载来自互联网的网页。它工作得非常好,直到我运行javascript网页。我怎么想解决这个问题?嗨迈克尔,
你的项目是什么类型的?它是一个Winform应用程序吗?
你是如何将javascript页面加载到webBrowser控件的?
请参考以下简单演示:
创建一个.html文件,如:
<!DOCTYPE HTML PUBLIC>
< html>
< head>
< title>< / title>
< script type =" text / javascript">
功能测试(消息){
alert(message);
}
< / script>
< / head>
< body>
< button onclick =" test('test from script code')"> Button< / button>
< / body>
< / html>然后在Form.cs中:
webBrowser1.Url = new Uri(@"C:\ Users \ [user] \ MyWinFrm \HTMLPage1.html");问候,
斯坦利
I am using web browser control in C# to load web pages from the internet. It works perfectly fine, until I run a javascript web page. How am I suppose to solve this problem?
解决方案
I am using web browser control in C# to load web pages from the internet. It works perfectly fine, until I run a javascript web page. How am I suppose to solve this problem?Hi Michael,
What the type of your project is? Is it a Winform app?
How did you load the javascript page to the webBrowser control?
Please refer to the following simple demo:
Create a .html file like:
<!DOCTYPE HTML PUBLIC> <html> <head> <title></title> <script type="text/javascript"> function test(message) { alert(message); } </script> </head> <body> <button onclick="test('test called from script code')">Button</button> </body> </html>Then in Form.cs:
webBrowser1.Url = new Uri(@"C:\Users\[user]\MyWinFrm\HTMLPage1.html");Regards,
Stanly
这篇关于如何在C#中使用Web浏览器控件运行javascript网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文