【发布时间】:2010-03-17 21:30:22
【问题描述】:
我在 index.html 上的网站是用 html+css 制作的,在我的 index.html 上我有这个 div id“内容”,您可以在其中将主要内容放入页面,并且菜单栏上有一个链接src 到 page2.php。当您按下链接时,它会转到 page2.php,但我希望它显示在
我不想使用框架.. 我应该在 index.php 上拆分我的设计,然后在 page2.php 上包含顶部和页脚吗?还是有其他方法
function test() {
var xhr = XMLHttpRequest();
xhr.onreadystatechange = function(){
if(xhr.readystate==4 && xhr.status=200)
document.getElementById('content').innerHTML = xhr.responseText;
};
xhr.open("GET", "start.php", false);
xhr.send(null);
}
<a href="start.php" onclick="test(); return false;">Hjem </a> |
<div id="content" ></div>
【问题讨论】:
-
为 Firefox 安装 Firebug 插件。更新了答案,检查一下。
-
我猜 ajax 对你来说太难了。所以坚持你最了解的。换个时间试试。