javascript:void(0) 调用时,WebBrowser 控件未完成加载 [英] WebBrowser control does not complete loading when javascript:void(0) called
问题描述
我有一个使用 WebBrowser
控件的 C# 应用程序.
在一个页面上,用户可以点击一个按钮来处理一些信息并导航到一个新页面.问题是当用户点击这个按钮时 WebBrowser
似乎停止了.
我处理了代码中的 Navigating
、Navigated
和 DocumentCompleted
事件,我看到了 Navigating
事件,但是然后没有别的.
这是被点击的按钮的 HTML:
点击其他页面上的按钮没有问题.
我假设它与 HTML 的 href="javascript:void(0);"
部分有关,但不知道为什么.在 IE 或 Firefox 等浏览器中,当单击此按钮时,会出现类似于进度条的内容,并说正在处理"几秒钟,然后加载下一页.
编辑:我应该提到导航处理程序触发两次,然后页面冻结.
这显然是由 IE7+ 的脚本 URL 缓解" 功能,可以通过禁用 FEATURE_SCRIPTURL_MITIGATION 为您的应用程序修复.
I have an application in C# which uses a WebBrowser
control.
On one page the user can click a button to process some information and navigate to a new page. The issue is that when the user clicks this button the WebBrowser
just seems to stop.
I handle the Navigating
, Navigated
and DocumentCompleted
events in my code and I see the Navigating
event but then nothing else.
This is the HTML for the button being clicked:
<div class="right button-wrapper">
<div class="clearfix right">
<span id="nextbutton"
class="button-link button-link btn-reg btn-blue-reg">
<span class="hasHover"><a id="btnPay"
href="javascript:void(0);" class="buttons">Next:Pay and Print</a>
</span>
</span>
</div>
</div>
Buttons on other pages can be clicked with no issues.
I am assuming it has something to do with the href="javascript:void(0);"
portion of the HTML but do not know why. In a browser such as IE or Firefox when this button is clicked something like a progress bar appears and say "Processing" for a few seconds and then the next page loads.
EDIT:I should mention that the Navigating handler fires twice and then the page freezes.
This is apparently caused by IE7+'s "Script URL Mitigation" feature and can be fixed for your application by disabling FEATURE_SCRIPTURL_MITIGATION.
这篇关于javascript:void(0) 调用时,WebBrowser 控件未完成加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!