编辑iframe内容 [英] Edit for iframe contents
本文介绍了编辑iframe内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
反正我可以在网页内编辑iframe的html内容吗?
Is there anyway I can edit the html content of an iframe inside a webpage?
我有以下代码:
<iframe src="sample.html"></iframe>
我想编辑 sample.html 的内容,而又不碰字面的html代码.我希望将此编辑器嵌入到网站中.非常感谢!
I want to edit the 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!
推荐答案
您可以像这样访问< iframe>
的文档:
You can access the document of the <iframe>
like so:
iframedoc = document.getElementById("my_iframe").contentDocument;
iframedoc.getElementById("element_in_iframe").do_something();
请注意,仅当iframe与您的父页面位于同一个域中时,此方法才有效.
Note that this only works if the iframe is on the same domain as your parent page.
这篇关于编辑iframe内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文