I have an iframe within the main window named "test_iframe".
I want to access the content of "test_iframe" within a google chrome extension.
I am trying to access the content of this iframe, but I am getting the following error-
Uncaught TypeError: Cannot read property 'contentWindow' of null
The javascript code I have used is given below-
var htmlvar = document.getElementById('te开发者_JAVA百科st_iframe').contentWindow.document.body.innerHTML;
What is wrong with the code? How can I make it work?
instead of test_iframe in coding try folllwing
<%=txtName.ClientID%>
i.e.
var htmlvar = document.getElementById('<%=txtName.ClientID%').contentWindow.document.body.innerHTML;
精彩评论