JSP中window.location.href"、"location.href"、"parent.location.href"、"top.location.href"和"target属性"的用法

来源:互联网 发布:qq免费刷赞软件下载 编辑:程序博客网 时间:2024/05/23 11:58

最近在工作中遇到这样一个问题,在frameset  frame框架(最常见的上-左-右框架)里面,点击上侧布局中的按钮,右侧的内容会一直增加,一直覆盖,而左侧的按钮的点击不了。自己学艺不精,上网查了很多,最终找到了解决方案。在action中加一个target=“top”就解决好了。就此总结一下经验。这个要了解 JSP中window.location.href"、"location.href"、"parent.location.href"、"top.location.href"和"target属性"的用法了。

window.location.href、location.href

功能:是对当前窗口自身的引用,本页面跳转。
语法:window.location.href=“跳转路径”
注:window.location.href,location.href是等价的。

top.location.href

功能:返回顶层窗口,即浏览器窗口,也是最外层的页面跳转。
语法:top.location.href=“跳转路径”
注:如果窗口本身就是顶层窗口,top属性返回的是对自身的引用。

parent.location.href

功能:返回父窗口,上一层页面跳转。

语法:parent.location.href=“跳转路径”

注:如果窗口本身是顶层窗口,parent属性返回的是对自身的引用。

在框架网页中,一般父窗口就是顶层窗口,但如果框架中还有框架,父窗口和顶层窗口就不一定相同了。

target的属性

_blank在新窗口中打开被链接文档。_self默认。在相同的框架中打开被链接文档。_parent在父框架集中打开被链接文档。_top在整个窗口中打开被链接文档。framename在指定的框架中打开被链接文档。

该属性常见用于<a></a>,也可用于action。也可以达到同样的效果。

注:

window.location.href、location.href效果等同于target=“_self”,即默认的

parent.location.href效果等同于target=“_parent”

top.location.href效果等同于target="_top";




阅读全文
0 0