JavaScript
中的window.location.href ()
和window.open()
方法有什么区别?
最佳答案
window.location
是一个 Object 和
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。
关于javascript - JavaScript 中的 Window.location.href() 和 Window.open(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18634383/