[英]Place HTML page into a div
How would I get window.location
into a div of the same HTML page?如何将
window.location
放入同一 HTML 页面的 div 中? Here's what I currently have:这是我目前拥有的:
function x {
var httpxml;
if (window.XMLHttpRequest) {
httpxml = new XMLHttpRequest();
}
else {
httpxml = new ActiveXObject("Microsoft.XMLHTTP");
}
httpxml.open("GET", "Home.aspx", true);
httpxml.send();
httpxml.onreadystatechange = function() {
if (httpxml.status == 200 && httpxml.readyState == 4) {
// what can i write here to show Home.aspx page into div at default.aspx page
}
}
}
Assuming your div
id
is div1
:假设您的
div
id
是div1
:
if (httpxml.status == 200 && httpxml.readyState == 4) {
document.getElementById("div1").innerHTML = httpxml.responseText;
}
You can simply use jQuery for this.为此,您可以简单地使用 jQuery。 Example:
例子:
$('div.class').load('mypage.html');
... or: ... 或者:
$('#mydivID').load('mypage.html');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.