繁体   English   中英

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

[英]Window.location.href () and Window.open () in JavaScript

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传递给要在新窗口中打开的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()将打开一个新窗口。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM