vb.net webbrowser控件,不刷新htmltext
我用谷歌搜索了中国的尽头和南美洲的尖端......我似乎找不到这个常见问题的具体解决方案。
我正在开发一个谷歌地图应用程序,并希望根据需要使用新的细节刷新地图。最初的问题当然是网络浏览器控件没有反映更改(仍然保留原始的 html 文本)和新的文档文本和刷新。我知道文档文本已设置一次,并且无法更改......显然。
我已经尝试了
navigate("about:blank")
document.stop
document.new(true)
doevents
所有收集的关于这个问题的用户知识,但只能让我成功一半。我可以使用上面的一些技术刷新页面,但它随后给我一个脚本错误和错误 53,这两个错误都没有详细信息或起源.. 只是空白错误.... 在单击错误窗口后,我的页面刷新。
任何人都可以阐明明确的解决方案吗?这真的是一个大问题吗?
PS 我不知道绑定到 webbrowser 控件的 javascript 事件是否会导致错误。有些人认为这些错误是由于文档加载而没有关闭/打开所有引用造成的......
有人可以救我免于疯狂吗?
I have googled far and wide to the ends of china and the tip of south america... I cant seem to find a concrete solution to this common problem.
I am developing a google maps ap, and want to refresh the map with new detail on demand. The initial problem offcourse was that the webbrowser control does not reflect the changes (still keeps the original htmltext) and new document text and refresh. I understand the document text is set once, and cant be changed... apparently.
I have tried
navigate("about:blank")
document.stop
document.new(true)
doevents
All the collected user knowledge on this problem, only get me half way. I can get the page refreshed using some of the techniques above, but it then gives me a script error and an error 53, which both has no details or origins.. just blank errors.... after clicking through their error windows, my page refreshes.
Can anyone shed some light on a clear cut solution. Can it really be this big of an issue?
P.S. I don't know if my javascript events that are bound to the webbrowser control causes the errors. Some have suggested that the errors are due to the document loading without all its references being closed/open...
Can someone please save me from insanity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
路易斯,你怎么样,伙计?我了解世界银行控制问题可能会破坏交易,我会帮助您,直到我们解决这个问题。但是,您能告诉我更多有关 HTMLText 和 DocumentText 的信息以及它们的含义吗?它们是 WB 控件的属性吗?我使用的是 .NET 之前的 WB 控件,它仍然主要是相同的东西,但 .NET 控件有一些更奇特的属性和功能。方法 :)。
好的,首先,您确定这个新的数据交换不是在框架或 iframe 内发生吗?因此,您看不到顶级 html 文档/页面的 HTML 文本有任何变化吗?我有一个函数,可以递归地获取对页面上所有框架以及这些框架中的所有框架的引用,即每个框架和所有嵌套框架,直至无限深度。这也许能帮到你。
另外,你用什么来获取文本? html 文档是一个实时文档,因为当元素发生变化时,DOM 也会发生变化,并且您从 DOM 中读取的内容也会更新,它是一个 100% 实时文档,并且只要您将文档声明为MSHTML.IHTMLDocument 那么你应该可以开始了。
最重要的是,我没有听到您提到 .innerText、.outerText、.innerHTML 和 .outerHTML。这些当然是您想要从中检索文本/源的项目。如果您想要完整的页面,请检查这些属性!因此,如果您想要 BODY 标记内的文本,您将执行以下操作:
比如说,IHTMLDocument 对象称为 hDoc。
这只会显示 BODY 标签内的文本,要获取 BODY 标签内的 HTML,只需执行此操作。
现在,如果您想要 BODY 标记中的 HTML,同时还检索开始和结束 BODY 标记,那么您可以这样做:
...等等...
当然,如果您出于某种原因想要刷新文档, 可以这样做:是webbrowser控件的刷新方法,它是WebBrowser1.Refresh,我认为有一个.Refresh2,其刷新逻辑略有不同。
我可以继续说下去,但我想知道在我们这样做之前我是否正确理解了你的问题。现在,唯一改变的是网络浏览器控件内地图的实时图像,不是吗?也许它周围还有一些文字,比如地址/等等?或者只是图像数据发生了变化(自从我使用谷歌地图以来已经有一段时间了,不确定您使用的是哪种实现),所以如果您能让我知道到底发生了什么变化以及您想要获取/阅读的内容,我应该能够更好地帮助你,总而言之,我保证会握住你的手,直到我们解决这个问题(笑) - 干杯,伙计,让我知道进展如何。
呃。
Louis, how are you mate? I understand how WB control issues can be deal breakers, I will help you out until we solve this issue. However, could you tell me more about the HTMLText and DocumentText and what you mean by them? are they properties of the WB control? I'm using a pre-.NET WB control, it is still mainly the same thing but the .NET one has a few more fancy properties & methods :).
Ok, first thing is first, are you SURE this new data exchange isn't happening inside a frame or an iframe? Hence, you are not able to see any change in the HTML text of the top-level html document/page? I have a function which recursively grabs references to all the frames on the page, and all the frames in those frames, being every single frame and all nested frames up to infinite-depth. That might be able to help you.
Also, what are you using to get the text? The html document is a LIVE document, in that, as elements change, the DOM changes, and what you read from the DOM will also be updated, it is a 100% live document, and as long as you are declaring your document as a MSHTML.IHTMLDocument then you should be good to go.
Most importantly, I didn't hear you mention .innerText, .outerText, .innerHTML and .outerHTML. These are of course the items you want to be retreiving text/source from. If you want the full pages, check those properties out! So, if you want the Text inside the BODY tags, you would do the following:
Say, out IHTMLDocument object is called hDoc.
That will show you only the text inside the BODY tags, to get the HTML inside the BODY tags, just do this.
Now, if you want the HTML in the BODY tags while also retreiving the starting and closing BODY tags, then you'd do this:
... etc...
Of course, if you want to refresh the document for whatever reason, there is a refresh method of the webbrowser control, it's WebBrowser1.Refresh and I think there is a .Refresh2 which has slightly different refresh logic.
I can go on and on, but would like to know I've understood your question correctly before we do. Now, the only thing that changes is the live Image of the map inside the webbrowser control, doesn't it? Perhaps some text around it as well like address/etc? Or is it just the image data that changes (been a while since I used google maps, and not sure which implementation you are using), so if you could let me know what exactly changes and what you are trying to pick up/read, I should be able to help you better, all in all, I promise to hold your hand until we figure this thing out (lol) - cheers mate, let me know how it goes.
Erx.