簡體   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