您的位置:首页 > 其它

页面跳转和iframe相互访问

2015-10-08 19:53 288 查看
页面跳转的方法:

假如有A,B,C三个页面,C是B的iframe, B是A的iframe

第一种:本页面的跳转

location = window.location =location.href = window.location.href =self.location.href = "url地址";
window.open("url地址","_self");


第二种:父页面的跳转

parent.location.href=window.parent.location.href=window.parent.window.location"url地址";
window.open("url地址","_parent");


第三种:祖父页面的跳转

parent.parent.location=top.location.href=window.top.location.href"url地址";
window.open("url地址","_top")==parent.open("url地址","_parent")=parent.parent.open("url地址","_self");


第四种:子页面的跳转

将iframe的src修改即可,如:<iframe src="D.html" name="sonIframe">;
window.sonIframe.location="D.html";


第五种:孙子页面的跳转

window.sonIframe.grandsonIframe.location="D.html";
window.sonIframe.document.getElementById('grandsonIframeId').src="D.html";


第六种:超链接
<a>
的跳转


<a href="D.html" target="_self">跳转到D.html页面</a> /*默认_self是在本窗口跳转*/
window.open("url地址","_blank");//默认_blank是在新窗口跳转


注意:可以通过设置target属性,实现不同方式的跳转页面。

多个嵌套iframe之间的相互访问全局变量和全局函数

第一种:子iframe的访问

调用方法:window.sonIframe.ff();
调用变量:window.sonIframe.vv;


第二种:父iframe的访问

调用方法:window.parent.ff();
调用变量:window.parent.vv;


第三种:最外层iframe的访问

调用方法:window.parent.parent.ff();
调用变量:window.top.vv;


第四种:平级iframe的访问

top.frames["sonIframeone"].sonIframeone("调用平级的另一个iframe的方法");


转载:——/article/5205380.html

转载:——http://www.doc88.com/p-570321598222.html

转载:——/article/1492414.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: