我需要 iframe 的 document.write 代码
我想要 document.write 代码加载页面(作为 iframe)
示例 - 我需要 document.write 函数来获取 http://google .com
我不想要 html 函数,而是想要 document.write
I want the document.write code to load a page(as iframe)
example - i need document.write function to get http://google.com
I dont want html function but as document.write
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您是否知道
document.write
方法的作用...document.write
方法用于将 HTML 代码写入当前文档。如果在加载时完成,代码将成为当前加载文档的一部分。如果在页面加载后完成,它将替换当前页面。您可以使用该方法将代码写入窗口或框架,但不能使用它来更改窗口的位置。即使您从 google.com 获取 HTML 代码并将其写入窗口,该位置也不会是 google.com,因此该代码很可能无法正常工作。
如果您想更改窗口的位置,只需使用
location.href
属性:I'm not sure that you know what the
document.write
method does...The
document.write
method is used to write HTML code into the current document. If it's done at load time, the code becomes part of the document currently loading. If it's done after the page has loaded, it will replace the current page.You can use the method to write code to a window or a frame, but you can't use it to change the location of the window. Even if you get the HTML code from google.com and write it to a window, the location will not be google.com so the code will most likely not work properly.
If you want to change the location of a window, you just use the
location.href
property: