简体   繁体   English

document.write整个页面,而不仅仅是框架

[英]document.write entire page, not just frame

I've got an HTML page with several frames. 我有一个带有多个框架的HTML页面。 I run a javascript in one of the frames to rewrite the entire page, ie get rid of all frames and rewrite the whole page. 我在其中一个框架中运行javascript以重写整个页面,即摆脱所有框架并重写整个页面。 But document.write only writes the frame it's written in. How can I do this with javascript? 但是document.write只写它所写的框架。我该如何使用javascript?

Cheers 干杯

If the frame and container are both on the same domain, you can use parent.document to access the whole HTML page. 如果框架和容器都在同一个域中,则可以使用parent.document访问整个HTML页面。

If they are on different domain, you cannot do this due to security restrictions. 如果它们在不同的域中,由于安全限制,您将无法执行此操作。

The global javascript object window.frames contains all frames. 全局javascript对象window.frames包含所有框架。 From this point you can edit all parts of your page. 至此,您可以编辑页面的所有部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM