使用可以使用此功能,这将解决您的问题,只需将您的 div Id 传递到您想要加载具有索引布局的页面内容的位置。在我的示例中,我将内容加载到容器 div 中。
/**
* Load page into url
*
* @param url The url to load
* @param onleave The function to call before leaving
* @param onenter The function to call after loading
*/
function loadPage(url, onleave, onenter)
{
alert(url);
console.log("loadPage("+url+")");
// If onleave function specified
if (onleave) {
onleave();
}
var xmlhttp = new XMLHttpRequest();
// Callback function when XMLHttpRequest is ready
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState === 4){
if (xmlhttp.status === 200) {
console.log("Received content"+xmlhttp.responseText);
document.getElementById('container').innerHTML = xmlhttp.responseText;
// If onenter function specified
if (onenter) {
onenter();
}
}
else {
document.getElementById('container').innerHTML = "Error loading page " + url;
}
}
};
xmlhttp.open("GET", url , true);
xmlhttp.send();
return;
}