I want to have a script rewrite a simple text-file opened up as the source of a frame -- one that lacks any html. I tried frames[1].document.innerHTML but without success. I even tried .outerHTML and got nothing. Can I either (a) get from the frame the entire contents of the frame to manipulate using the script and then .write() back the result to the frame? Or (b) add <html> and <div> tags, wrapping the document so I can get the inner html and then manipulate that? Any help appreciated.
As long as your main page and iFrame page follow Same Origin policy, you can access frame's html like this:
window.frames['iframe01'].document.body.innerHTML
or
window.frames['iframe01'].contentDocument.documentElement.innerHTML
To write:
window.frames['iframe01'].contentDocument.write("[content here]");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With