JavaScript中的Window.location.href()和Window.open()

JavaScript中的Window.location.href()和Window.open(),javascript,windows,Javascript,Windows,JavaScript中的window.location.href()和window.open()方法之间有什么区别?window.location.href更改即时窗口位置 window.open()将打开一个新窗口。window.location是一个对象 window.location.href是它的属性 它告诉您浏览器的当前URL位置 document.write(location.href);// will give location URL location of browser.

JavaScript
中的
window.location.href()
window.open()
方法之间有什么区别?

window.location.href
更改即时窗口位置


window.open()
将打开一个新窗口。

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'; //将带您到xyz。

window.open('http://www.xyz.com'); //这将在新窗口中打开xyz。

的可能重复项