转 top.location.href和localtion.href有什么不同
2015-06-09 15:01
344 查看
<div class="postTitle" style="font-size: 14.7px; font-weight: bold; margin-bottom: 10px; font-family: verdana, Arial, helvetica, sans-seriff;"><span style="color: rgb(75, 75, 75); line-height: 19.200000762939453px; font-size: 14px;">top.location.href=”url” <span style="white-space: pre;"> </span>在顶层页面打开url(跳出框架) </span><a target=_blank target="_blank" name="baidusnap0" class=" " style="color: rgb(75, 75, 75); line-height: 19.200000762939453px; background-color: rgb(240, 240, 240); font-size: 14px;"></a></div><div class="postTitle" style="font-size: 14.7px; font-weight: bold; margin-bottom: 10px; font-family: verdana, Arial, helvetica, sans-seriff;"><span style="color: black; line-height: 19.200000762939453px; font-size: 14px; background-color: rgb(255, 255, 102);">self.location.href</span><span style="color: rgb(75, 75, 75); line-height: 19.200000762939453px; font-size: 14px;">=”url” <span style="white-space: pre;"> </span>仅在本页面打开url地址 </span></div><div class="postTitle" style="color: rgb(75, 75, 75); font-size: 14.7px; font-weight: bold; margin-bottom: 10px; font-family: verdana, Arial, helvetica, sans-seriff;"><span style="line-height: 19.200000762939453px; font-size: 14px;">parent.location.href=”url” 在父窗口打开Url地址 </span></div><div class="postTitle" style="color: rgb(75, 75, 75); font-size: 14.7px; font-weight: bold; margin-bottom: 10px; font-family: verdana, Arial, helvetica, sans-seriff;"><span style="line-height: 19.200000762939453px; font-size: 14px;">this.location.href=”url” <span style="white-space: pre;"> </span>用法和self的用法一致 </span></div><div class="postTitle" style="color: rgb(75, 75, 75); font-size: 14.7px; font-weight: bold; margin-bottom: 10px; font-family: verdana, Arial, helvetica, sans-seriff;"><span style="line-height: 19.200000762939453px; font-size: 14px;"> </span></div><div class="postTitle" style="color: rgb(75, 75, 75); font-size: 14.7px; font-weight: bold; margin-bottom: 10px; font-family: verdana, Arial, helvetica, sans-seriff;"><span style="line-height: 19.200000762939453px; font-size: 14px;">if (top.location == self.location) 判断当前location 是否为顶层来 </span><span style="font-size: 14px; line-height: 1.5; color: rgb(250, 128, 114);">禁止frame引用</span><span style="line-height: 19.200000762939453px; font-size: 14px;"> </span></div><div class="postTitle" style="color: rgb(75, 75, 75); font-size: 14.7px; font-weight: bold; margin-bottom: 10px; font-family: verdana, Arial, helvetica, sans-seriff;"><span style="line-height: 19.200000762939453px; font-size: 14px;">如果页面当中有自定义的frame的话,也可以将parent self top换为自定义frame的名称 效果就是在自定义frame窗口打开url地址</span><p style="margin: 10px auto; line-height: 19.200000762939453px;"> </p><p style="margin: 10px auto; line-height: 19.200000762939453px;">实际中可能这样使用</p><p style="margin: 10px auto; line-height: 19.200000762939453px;"> if(top !== self){ top.location.href = location.href; } <span style="line-height: 1.5; color: rgb(250, 128, 114);">禁止frame引用</span></p><p style="margin: 10px auto; line-height: 19.200000762939453px;"><span style="line-height: 1.5; color: rgb(250, 128, 114);">http://blog.csdn.net/lisheng19870305/article/details/41074893 </span></p></div>
相关文章推荐
- Android或Linux调试addr2line工具锁定命令的使用
- 使用DNS轮询+NGINX+PHP+NFS+MYSQL实现集群高可用
- nginx一些基本的优化配置
- at91sam9260ek的板级、irq初始化-小试牛刀
- linux下jdk配置
- centos下postgres源码编译
- hadoop相关问题-stop-all.sh
- linux 的date命令及系统时间设置
- 如何用mod_jk连接器来集成Apache2和Tomcat 7
- Window_Open详解
- linux安装jdk、tomcat
- 一个很不错的bash脚本编写教程
- ZH奶酪:Linux/Ubuntu 安装/卸载 软件
- linux下安装jboss6+jdk1.7
- vnc viewer for linux
- Linux中的AIO(异步I/O asynchronous I/O )
- Ubuntu 14.04一步一步安装Openstack Kilo版本-15(Sahara)
- Ubuntu 14.04一步一步安装Openstack Kilo版本-14(ceilometer)
- Optimizer统计信息管理介绍
- Ubuntu 14.04一步一步安装Openstack Kilo版本-13(heat)