Is there anyway I can edit the html content of an iframe inside a webpage?
I have the following code:
<iframe src="sample.html"></iframe>
I want to edit th开发者_StackOverflow社区e contents of sample.html without literally touching the html code. And I want this editor to be embedded on the website. Thank you so much!
You can access the document of the <iframe>
like so:
iframedoc = document.getElementById("my_iframe").contentDocument;
iframedoc.getElementById("element_in_iframe").do_something();
Note that this only works if the iframe is on the same domain as your parent page.
精彩评论