javascript中window.open()与window.location.href的区别

window.open()

open() 方法用于打开一个新的浏览器窗口或查找一个已命名的窗口。

window.open(pageURL,name,parameters)  

其中:pageURL 为子窗口路径

name 为子窗口句柄

parameters 为窗口参数(各参数用逗号分隔) 

window.open("index.jsp",'top'); 只是表示打开这个页面,并不是打开并刷新index.aspx

window.location.href

 表示重新定向到新页面,同时刷新打开的这个页面;

js页面的书写(案例)

 

self.location.href="/url" 当前页面打开URL页面
location.href="/url" 当前页面打开URL页面
windows.location.href="/url" 当前页面打开URL页面,前面三个用法相同。
this.location.href="/url" 当前页面打开URL页面
parent.location.href="/url" 在父页面打开新页面
top.location.href="/url" 在顶层页面打开新页面

 

个人总结

详细请看

http://blog.csdn.net/xiaobing_122613/article/details/72763569

posted @ 2018-01-05 18:38  potent_prince  阅读(267)  评论(0编辑  收藏  举报