【发布时间】:2013-09-09 04:09:21
【问题描述】:
JavaScript 中的window.location.href () 和window.open() 方法有什么区别?
【问题讨论】:
标签: javascript windows
JavaScript 中的window.location.href () 和window.open() 方法有什么区别?
【问题讨论】:
标签: javascript windows
window.location 是一个对象和
window.location.href 是它的属性
它告诉你浏览器的当前 URL 位置
document.write(location.href);// will give location URL location of browser.
设置属性将重定向页面。
window.open() 是一种方法,您可以将 URL 传递给您想要在新窗口中打开
例如
window.location.href = 'http://www.xyz.com'; //Will take you to xyz.
window.open('http://www.xyz.com'); //This will open xyz in a new window.
【讨论】:
window.location.href 更改即时窗口位置。
window.open() 将打开一个新窗口。
【讨论】: