Need Help in getting XPath expression for span inside an Iframe popup

前端 未结 5 463
清歌不尽
清歌不尽 2021-01-02 23:30

Need to get an xpath expression for the span inside the iframe. Need Help in getting XPath expression for span inside an Iframe popup.

i can get the iframe but getti

5条回答
  •  一生所求
    2021-01-02 23:46

    You need to set the scope of the xpath to the iframe's contentDocument property:

    var iframe = document.getElementsByTagName("iframe")[0];
    var theFirstSpan = document.evaluate('//span', iframe.contentDocument,
             null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
    

提交回复
热议问题