【问题标题】:Window.location.href () and Window.open () in JavaScriptJavaScript 中的 Window.location.href() 和 Window.open()
【发布时间】:2013-09-09 04:09:21
【问题描述】:

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

【问题讨论】:

标签: javascript windows


【解决方案1】:

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.

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 2011-10-28
      • 2019-08-13
      • 1970-01-01
      • 2011-06-16
      • 2010-09-19
      • 1970-01-01
      • 1970-01-01
      • 2011-01-25
      相关资源
      最近更新 更多