location.href 几种用法

self.location.href;//当前页面打开URL页面
window.location.href;//当前页面打开URL页面
this .location.href;//当前页面打开URL页面
location.href;// 当前页面打开URL页面
parent.location.href;//在父页面打开新页面

top.location.href;//在顶层页面打开新页面 



上图,效果如下

location.href 几种用法_第1张图片


如下四个当前页面打开url页面效果如下

self.location.href;//当前页面打开URL页面
window.location.href;//当前页面打开URL页面
this .location.href;//当前页面打开URL页面
location.href;// 当前页面打开URL页面
location.href 几种用法_第2张图片


如下两个 效果如下:

parent.location.href;//在父页面打开新页面

top.location.href;//在顶层页面打开新页面 

location.href 几种用法_第3张图片

这两个效果是有区别的,只是我这个最外面的页面就是上一层页面(父页面),所以这里效果是一样

"top.location.href"是最外层的页面跳转

"parent.location.href"是上一层页面跳转.

你可能感兴趣的:(web前端,java)