DocumentCompleted发射多次 - 接受StackOverflow的答案不工作 [英] DocumentCompleted firing multiple times - accepted StackOverflow answer not working
问题描述
我测试,如果我的web浏览器中完成了:
I test if my WebBrowser is completed with:
webBrowser2.DocumentCompleted += (s, e) =>
{
// Do stuff
}
我作为访问吨JS文件和iframe中和东西的网页,所以我用下面的功能,以确保它是一个的装载完成实际的页面。
The webpage I am accessing as tons of JS files and iframes and stuff, so I use the below function to make sure it's the actual page that's completed loading.
webBrowser2.DocumentCompleted += (s, e) =>
{
if (e.Url.AbsolutePath != (s as WebBrowser).Url.AbsolutePath)
{
return;
}
// Do stuff
}
但是,它仍然没有出现奏效。难道我做错了什么,或者这是语法正确,并有一个在我的code其他错误?
However, it still doesn't appear to be working. Am I doing something wrong or is this syntactically correct and there's some other error in my code?
推荐答案
的DocumentComplete
可能会的原因有很多(框架,AJAX等)解雇了多次。同时,对于一个特定的文件,的window.onload
事件将被一次发射。也许,你可以在的window.onload
做你的处理。我刚才已经回答了如何可以做一个相关问题。
DocumentComplete
may get fired multiple times for many reasons (frames, ajax, etc). At the same time, for a particular document, window.onload
event will be fired only once. So, perhaps, you can do your processing upon window.onload
. I just answered a related question on how that can be done.
这篇关于DocumentCompleted发射多次 - 接受StackOverflow的答案不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!