更新时间:2023-09-01 08:03:46
我在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