我想做到:IFRAME里的子页面翻页后,父页面的URL地址跟着更新。
下面的代码可以更换URL地址,但是IFRAME的地址没有更新,切换'../index.php?page=1','../index.php?page=2','../index.php?page=3',IFRAME里都是page/1.php,我希望是'../index.php?page=2'时嵌入的是page/2.php,'../index.php?page=3'时嵌入的是page/3.php,求高手们给修正一下。index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
String.prototype.getQuery = function(name) {
var reg = new RegExp('\\b'+name+'=([^&].*)(&|$)', 'i');
var arr = this.match(reg);
return (arr && arr[1]) ? unescape(arr[1]) : null;
}
window.onload = function(){
var url = window.location.href.toString();
var page = url.getQuery('page');
if (page) document.getElementById('items').src = 'page/' + page + '.php';
}
</script>
</head>
<body>
<iframe id="items" src="page/1.php" frameborder="1" scrolling="no" height="40"></iframe>
</body>
</html>
page/1.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
页面A
<input type="button" value="PAGEA" onclick="parent.window.location = '../index.php?page=1';" />
<input type="button" value="PAGEB" onclick="parent.window.location = '../index.php?page=2';" />
<input type="button" value="PAGEC" onclick="parent.window.location = '../index.php?page=3;" />
</body>
</html>
下面的代码可以更换URL地址,但是IFRAME的地址没有更新,切换'../index.php?page=1','../index.php?page=2','../index.php?page=3',IFRAME里都是page/1.php,我希望是'../index.php?page=2'时嵌入的是page/2.php,'../index.php?page=3'时嵌入的是page/3.php,求高手们给修正一下。index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
String.prototype.getQuery = function(name) {
var reg = new RegExp('\\b'+name+'=([^&].*)(&|$)', 'i');
var arr = this.match(reg);
return (arr && arr[1]) ? unescape(arr[1]) : null;
}
window.onload = function(){
var url = window.location.href.toString();
var page = url.getQuery('page');
if (page) document.getElementById('items').src = 'page/' + page + '.php';
}
</script>
</head>
<body>
<iframe id="items" src="page/1.php" frameborder="1" scrolling="no" height="40"></iframe>
</body>
</html>
page/1.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
页面A
<input type="button" value="PAGEA" onclick="parent.window.location = '../index.php?page=1';" />
<input type="button" value="PAGEB" onclick="parent.window.location = '../index.php?page=2';" />
<input type="button" value="PAGEC" onclick="parent.window.location = '../index.php?page=3;" />
</body>
</html>
解决方案 »
- 求一个基于jQuery框架的日期时间控件
- jquey 问题
- WEB窗口焦点问题
- 如何定时让内容一行一行输出来,而不是一下子就都出来
- 不知道为什么,数组问题。
- 求一个js代码来取出整个页面特定标签处的内容并进行css属性修改.
- jquery跨域 获取数据 ################################ 100%结贴,两个贴一起结
- 如何javascript得到和本页面同属一个域的所有窗口的句柄?
- 在弹出窗口中刷新父页面中的iframe中包含的页面
- 我想作一个象sohu的webpager的东西.请教
- HTML 页面传值问题。
- [散份][原创]用javascript开发的任务管理组件 v0.03 (20100710)
差一个单引号
index.php的代码没有问题吗?
我怎么试不出效果的……