我想在登录公司网站时显示欢迎页面。目前,此页面包含一些帐户摘要数据/详细信息。我希望能够使用相同的空间来显示结算信息,但我不希望用户离开他们所在的页面。
我怎样才能做到这一点?我必须能够在已加载的页面中放置此代码。
答案 0 :(得分:3)
您可以像这样使用iframe:
<iframe src="http://www.w3schools.com"></iframe>
src =“blahblah”可以切换到您想要的任何网站或页面。
虽然iframe听起来不像适合您需要的东西。听起来您需要根据是否是第一次访问该页面来添加内容。您可以使用php或javascript来抓取cookie并执行此操作。
答案 1 :(得分:0)
您必须对页面进行ajax调用以获取数据并将响应附加到要显示的div。
使用jquery $ .ajax
答案 2 :(得分:0)
var div = document.getElementById ("your_div_ID_goes_here");
div.innerHTML = "<b>Any html content. <br> Enjoy!</b>";
这将有助于你:)
答案 3 :(得分:0)
以下是动态加载其他URL内容的代码(AJAX)。 你不需要jQuery只是为了这个简单的任务
function loadXMLDoc(aURL){
var xmlhttp;
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
var div = document.getElementById ("your_div_ID_goes_here");
div.innerHTML = xmlhttp.responseText; // this is the content you received,
}
}
xmlhttp.open("GET",aURL,true);
xmlhttp.send();
}