Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.(注意:本文中的建议仅适用于JxBrowser6,JxBrowser7相应文章请点击这里。)

Each web page loaded in the browser has its own document object. To access document object of loaded web page use the Browser.getDocument() method. This method returns DOMDocument instance that you can use to access document's properties and its child nodes. For example: (浏览器中加载的每个网页都有自己的文档对象。要访问已加载网页的文档对象,请使用Browser.getDocument()方法。此方法返回DOMDocument实例,可用于访问文档的属性及其子节点。例如:)

DOMDocument document = browser.getDocument();

If web page contains frames (see IFRAME or FRAME), then each frame has its own document object. To access document object of a specified frame use the Browser.getDocument(long frameId) method. The frameId you can obtain from the Browser.getFramesIds() method. For example: (如果网页包含框架(请参阅IFRAME或FRAME),则每个框架都有其自己的文档对象。要访问指定框架的文档对象,请使用Browser.getDocument(long frameId)方法。您可以从Browser.getFramesIds()方法获得的frameId。例如:)

for (Long frameId : browser.getFramesIds()) {
    DOMDocument frameDocument = browser.getDocument(frameId);

Having DOMDocument instance you can work with the document object and its DOM structure.(具有DOMDocument实例,您可以使用文档对象及其DOM结构。)

If web page isn't completely loaded or it doesn't have document, then the Browser.getDocument() method returns null. So, before you invoke this method, make sure that web page is loaded completely.(如果网页未完全加载或没有文档,则Browser.getDocument()方法将返回null。因此,在调用此方法之前,请确保已完全加载网页。)