WebBrowser:如何查看JavaScript对DOM所做的更新? [英] WebBrowser: how to see updates to DOM made by JavaScript?

查看:59
本文介绍了WebBrowser:如何查看JavaScript对DOM所做的更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果正在用JavaScript更新WebBrowser控件中显示的网页,是否可以获取反映该脚本所做更改的更新的DOM文档?

例如,请转到要访问starbucks.com,请在"Store Locator"(商店定位器)中输入美国邮政编码.对话框,然后单击开始".该页面将显示您是不是要...". JavaScript创建的消歧对话框:脚本创建HTML字符串,然后在位置框中设置div的innerHTML属性.

在我的代码中,我创建了一个WebBrowser控件并导航至starbucks.com.页面加载后,按预期,我收到一个DocumentCompleted事件.然后,我(以编程方式)输入邮政编码,然后点击转到"按钮.在WebBrowser中,我看到您是不是要..."对话框显示,并且我收到第二个DocumentCompleted事件.但是,WebBrowser.Document尚未更改,并且由JavaScript更新的div与首次加载页面时相同.我还尝试过调用ExecuteScript("document.getElementByID(\" div_name"\")),该方法仅返回null,因此也没有运气.

If a web page being displayed in a WebBrowser control is being updated by JavaScript, is it possible to get an updated DOM document that reflects the changes made by that script?

For example, go to starbucks.com, enter a US zip code into the "Store Locator" dialog box at the top right, then click "go". The page will display a "Did you mean..." disambiguation dialog box that is created by JavaScript: a script creates an HTML string, then sets the innerHTML property of a div in the location box.

In my code, I create a WebBrowser control and Navigate to starbucks.com. When the page loads, I receive a DocumentCompleted event, as expected. I then (programmatically) enter a zip code and click the "go" button. In the WebBrowser, I see the "Did you mean..." dialog being displayed, and I receive a second DocumentCompleted event. WebBrowser.Document, however, has not changed, and the div that was updated by the JavaScript is as it was when the page first loaded. I've also tried calling ExecuteScript("document.getElementByID(\"div_name"\"), which only returns null, so no luck there either.

Any suggestions? Or can the WebBrowser control only deal with full page loads?

推荐答案

谢谢为您的帖子!不幸的是,目前没有论坛发布您要提问的问题,因此我建议您将问题发布到以下Microsoft.public.internetexplorer.general新闻组之一: 希望帮助!


这篇关于WebBrowser:如何查看JavaScript对DOM所做的更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆