如何将网页加载到< div>元素? [英] How can I load a webpage into a <div> element?
问题描述
我对Java语言还很陌生,并且有一个关于将网页加载到网站上的div元素("content-window")中的问题.我想在该div中打开一个网页,在这种情况下, http://www.fdsa.com?ID=1 .我必须编写以下行才能选择div元素.
I'm quite new to Javascript and I have a question about loading a webpage into a div element ('content-window') on my website. I want to open a webpage in that div, in this case http://www.fdsa.com?ID=1. I've to write the following line in order to select the div element.
var sidediv = document.getElementById('content-window');
有人可以告诉我如何将网页加载到此div中吗?我已经尝试了很多(但是我当然失败了).例如,以下行将不起作用:
Can someone tell me how can I load a webpage into this side div? I've tried a lot (but I've failed of course). For example, the following line won't work:
sidediv.location.assign = "http://www.fdsa.com?ID=1";
提前谢谢!
推荐答案
您应该使用< iframe>
标记,如下所示:
you should use an <iframe>
tag as follows:
<div>
<iframe src="http://www.fdsa.com?ID=1">
</div>
或以编程方式构建它:
document.getElementById("content-window").innerHTML ='< iframe src ="http://www.fdsa.com?ID=1">'
您可以在此处使用更多的< iframe>
信息: https://developer.mozilla.org/en/docs/Web/HTML/Element/iframe
you could use more <iframe>
information here:
https://developer.mozilla.org/en/docs/Web/HTML/Element/iframe
享受!
这篇关于如何将网页加载到< div>元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!