Access external HTML page content of object tags

前端 未结 3 879
清歌不尽
清歌不尽 2021-01-14 14:47

I\'ve searched an answer to this question but can\'t get a way how to do it.

I want to access the content of a div that I have included in an object tag.

My

相关标签:
3条回答
  • 2021-01-14 14:58

    Got it! Just use

    window.parent.mainPageMethod(document.getElementById("includedDiv").firstChild.nodeValue);
    

    in the included page and you can get div content in a Javascript function from the main page!

    Thanks for trying to help Jay, I should admit that when you talked about window.name property it put me on the right direction :)

    0 讨论(0)
  • 2021-01-14 15:14

    Even better answer: you CAN access object tag content through the DOM, it is just another window!

    window[0].document.getElementById("includedDiv").firstChild.nodeValue;
    

    That's it :D http://www.w3schools.com/jsref/prop_win_length.asp

    0 讨论(0)
  • 2021-01-14 15:16

    document.getElementById('id').innerHTML or document.getElementById('id').outerHTML whichever you are looking for...

    see how to append to a object with innerHTML

    0 讨论(0)
提交回复
热议问题