开发者

error when i try to obtain content of an iframe using javascript code as shown

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; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜