I've got an index page and I want to load on a DIV another page from a very different directory, but I want that the page that will be loaded into the DIV to keep the CSS and JS includes, is it possible?
It seems that it only loads into the DIV, the body of the other page and forget the JS and CSS includes.
I'm using this code to load the HTML into the div:
<script type="text/javascript">
function processAjax(url) {
if (window.XMLHttpRequest) { // Non-IE browsers
req = new XMLHttpRequest();
req.onreadystatechange = targetDiv;
try {
req.open("GET", url, true);
} catch (e) {
alert(e);
}
req.send(null);
} else if (window.ActiveXObject) { // IE
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = targetDiv;
req.open("GET", url, true);
req.send();
}
}
}
function targetDiv() {
if (req.readyState == 4) { // Complete
if (req.status == 200) { // OK response
document.getElementById("mContent").innerHTML = req.responseText;
} else {
alert("Problem: " + req.statusText);
}
}
}
</script>
<a href="javascript:processAjax('./DataTables/extras/Editor/treinamentos/index.html');">My Page</a>
为什么不使用包含要与要使用的js和css一起显示的页面的URL的IFRAME标记。
<iframe src="mypage.html"></iframe>
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.