简体   繁体   English

WebBrowser控制脚本错误

[英]WebBrowser Controls Script error

I am making a bot which visits to a specific url, give the input in form and submit it by clicking to submit button... 我正在制作一个访问特定网址的机器人,以表格形式提供输入内容,然后通过单击提交按钮来提交它...

Let me explain you my situation. 让我解释一下我的情况。 When I start my bot, firstly it visits the URL, after web page is loaded, I have to check one radio button manually there and after this I press submit button (windows form control button to fill all fields of web page and submit it also by using invoke click method) to submit form. 当我启动我的机器人时,首先它访问URL,在加载网页后,我必须在那里手动检查一个单选按钮,然后按Submit按钮(Windows窗体控制按钮填充网页的所有字段并提交)通过使用invoke click方法)来提交表单。

I am using Web browser control (coding in C#.NET windows form) and the problem is when I click on a radio button, a pop up window pops up with the heading "Script Error" and says 我正在使用Web浏览器控件(以C#.NET Windows窗体编码),问题是当我单击单选按钮时,弹出窗口弹出,标题为“脚本错误”,并说 在此处输入图片说明

Below is the tag of radio button (on which error pops up) which I copied by using IE development tool. 下面是我使用IE开发工具复制的单选按钮的标签(弹出错误)。

<input name="array(BlastDatabaseType)" onchange="changeQuestion(); changeAlgorithms();"
type="radio" value="Proteins"/>

This error don't occur on normal web browser. 在普通的Web浏览器上不会发生此错误。 I want to solve this error not to hide. 我想解决这个错误不要隐藏。

What I have understood from your question that you need to fix the javascript error which is generated due to Web browser Control, 从您的问题中我了解到,您需要修复由于Web浏览器控件而产生的javascript错误,

There are two basic solutions, 有两种基本解决方案,

1) Force the Web Browser control to emulate the latest IE browser. 1)强制Web浏览器控件模拟最新的IE浏览器。 You need to make a registry change for this ,and you will be able to use the IE browser installed on the PC. 您需要对此进行注册表更改,然后才能使用PC上安装的IE浏览器。

Adapted from Mikel Solution 改编自Mikel解决方案
You can use a meta tag <meta http-equiv="X-UA-Compatible" content="IE=9" > inside the HTML page. 您可以在HTML页面内使用元标记<meta http-equiv="X-UA-Compatible" content="IE=9" >

But its better to add a registry entry to: (goto > start > run > type 'regedit' enter) 但最好在以下位置添加注册表项:( (goto > start > run > type 'regedit' enter)

HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER) > SOFTWARE > Microsoft > Internet Explorer > Main > FeatureControl > FEATURE_BROWSER_EMULATION > contoso.exe = (DWORD) 00009000

use 10000 (0x02710) for Internet Explorer 10 对Internet Explorer 10使用10000 (0x02710)

2) Use the GeckoFX wrapper ,it wraps the Gecko engine, 2)使用GeckoFX包装器,它包装了Gecko引擎,
Download the GeckoFX wrapper 下载 GeckoFX包装器
Download the XulRunner 下载 XulRunner

First extract the GeckoFX and read the readme.txt file. 首先解压缩GeckoFX并读取readme.txt文件。

Add reference of the Gecko.dll in you toolbar ,and then drag and drop the control on your Form. 在工具栏中添加Gecko.dll的引用,然后将控件拖放到窗体上。

public Form1()
    {
        InitializeComponent();
        //you need to extract the Xulrunner in the soultion directory
        //  (preferable) b/c wrapper relies on these dlls.
        Skybound.Gecko.Xpcom.Initialize(@"C:\Xulrunner");
    }

    private void Form1_Load(object sender, EventArgs e)
    {
       geckoWebBrowser1.Navigate("http://tritrypdb.org/tritrypdb/"); 
    }


Other useful Links: 其他有用的链接:
http://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation http://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation
Will the IE9 WebBrowser Control Support all of IE9's features, including SVG? IE9 WebBrowser控件是否支持IE9的所有功能,包括SVG?

IE handles differently the onchange event. IE处理onchange事件的方式有所不同。 IE only fires the onchange event when the element loses focus. IE仅在元素失去焦点时才触发onchange事件。

If I understood your question correctly, You might want to use onkeypress event instead. 如果我正确理解了您的问题,则可能要改用onkeypress事件。

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

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