How would I get window.location
into a div of the same HTML page? 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
:
if (httpxml.status == 200 && httpxml.readyState == 4) {
document.getElementById("div1").innerHTML = httpxml.responseText;
}
You can simply use jQuery for this. Example:
$('div.class').load('mypage.html');
... or:
$('#mydivID').load('mypage.html');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.