Tanoru Posted January 29, 2011 Share Posted January 29, 2011 I'm trying to change the content of an element from withing an iframe. If I use this: $('body').replaceWith("hi"); then the content of a iframe is replaced correctly. However when I try to access the parent document it doesn't work. I've been using this code: $('body', window.parent.document).replaceWith("hi"); What is the correct way to do this? Link to comment Share on other sites More sharing options...
0 sweetsam Posted January 29, 2011 Share Posted January 29, 2011 I'm trying to change the content of an element from withing an iframe. If I use this: $('body').replaceWith("hi"); then the content of a iframe is replaced correctly. However when I try to access the parent document it doesn't work. I've been using this code: $('body', window.parent.document).replaceWith("hi"); What is the correct way to do this? I am not sure about this but there in an error in your code... $('body', window.parent.document).replaceWith("hi"); should be... $('body', window.parent.document.replaceWith("hi")); Link to comment Share on other sites More sharing options...
0 Tanoru Posted January 29, 2011 Author Share Posted January 29, 2011 Thanks for pointing that out. Unfortunately that hasn't fixed it =[ Link to comment Share on other sites More sharing options...
0 Tanoru Posted January 29, 2011 Author Share Posted January 29, 2011 Can someone please take the time to help me. I've trying to do this for so long now that I'm ready to scrap the whole thing and I don't want to do that. Link to comment Share on other sites More sharing options...
Question
Tanoru
I'm trying to change the content of an element from withing an iframe.
If I use this:
$('body').replaceWith("hi");then the content of a iframe is replaced correctly.
However when I try to access the parent document it doesn't work. I've been using this code:
$('body', window.parent.document).replaceWith("hi");What is the correct way to do this?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts