top.location.href和localtion.href有什么不同
来源:互联网 发布:淘宝袜子利润 编辑:程序博客网 时间:2024/05/16 06:35
top.location.href=”url” 在顶层页面打开url(跳出框架)
self.location.href=”url” 仅在本页面打开url地址
parent.location.href=”url” 在父窗口打开Url地址
this.location.href=”url” 用法和self的用法一致
if (top.location == self.location) 判断当前location 是否为顶层来 禁止frame引用 如果页面当中有自定义的frame的话,也可以将parent self top换为自定义frame的名称 效果就是在自定义frame窗口打开url地址
实际中可能这样使用
if(top !== self){ top.location.href = location.href; } 禁止frame引用
以下是从网上找到的一个例子,不是很直观, 我加了上面那三行代码, 可以先去掉, 再加上, 看一下效果,就很清楚了 以下是top.htm 代码 <script language=JavaScript> function rs(){
if(top !== self){
top.location.href = location.href;
}
parent.left.location.href="top.htm" parent.bot.location.href="top.htm" } < /script> < input type=button name=name value="ksdj" onclick=rs();>
以下是一个随意文件名的htm文件: <FRAMESET COLS="150,*"> < FRAME SRC="left.htm" name=left> < FRAMESET ROWS="150,*"> < FRAME SRC="top.htm" name=top> < FRAME SRC="bot.htm" name=bot> < /FRAMESET> < /FRAMESET> 你自己试试,我想你要的可能就是这样的效果!
top表示主窗口,location表示当前窗口,如果你的文件只有一个框架,没有iframe和frmaeset,那么是完全一致的,没有区别。
这是从博客园转载过来的http://www.cnblogs.com/liangyu/articles/2530884.html。
- top.location.href和localtion.href有什么不同
- top.location.href和localtion.href有什么不同
- top.location.href和localtion.href有什么不同
- 转 top.location.href和localtion.href有什么不同
- top.location.href和localtion.href有什么不同
- top.location.href和localtion.href有什么不同
- top.location.href和localtion.href有什么不同
- top.localtion.href和top.localtion.replace
- window.top.location.href 和 window.location.href 的区别
- window.top.location.href 和 window.location.href 的区别
- window.location.href和window.top.location.href的区别
- window.location.href和window.top.location.href的区别
- $state.go和$location.href有什么区别
- top.location.href"、"window.location.href"和"parent.location.href"的区
- JSP中window.location.href"、"location.href"、"parent.location.href"、"top.location.href"和"target属性"的用法
- top.location.href windows.location.href
- top.location.href = window.location.href;
- top.location.href、parent.location.href
- 关于mysql 查询 按汉字的首字母进行排序和查找某个以某字母开头的谋汉字
- 部分字节对齐内容整理(适用于C++中)
- Tips—1(c标签)
- sizeof和strlen与数组之间的恩恩怨怨
- C#基础之显示当前时间
- top.location.href和localtion.href有什么不同
- 面试总结
- 大整数运算
- Shiro导致request.getInputStream()无法获取数据
- 欢迎使用CSDN-markdown编辑器
- Erlang学习笔记(三)Erlang基础语法
- 关于空指针NULL、野指针、通用指针
- javascript-入门
- cocos2d-js 播放音频文件