JavaScript中的Window.location.href和Window.open()方法 [英] Window.location.href and Window.open () methods in JavaScript

查看:680
本文介绍了JavaScript中的Window.location.href和Window.open()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What is the difference between window.location.href and window.open () methods in JavaScript?

推荐答案

window.location.href 一个方法,它是一个告诉您浏览器当前URL位置的属性。更改属性的值将重定向页面。

window.location.href is not a method, it's a property that will tell you the current URL location of the browser. Changing the value of the property will redirect the page.

window.open()是一种方法,你可以将URL传递给您要在新窗口中打开的URL。例如:

window.open() is a method that you can pass a URL to that you want to open in a new window. For example:

window.location.href示例:

window.location.href = 'http://www.google.com'; //Will take you to Google.

window.open()示例:

window.open('http://www.google.com'); //This will open Google in a new window.



附加信息:


Additional Information:

window.open()可以传递其他参数。请参阅: window.open教程

window.open() can be passed additional parameters. See: window.open tutorial

这篇关于JavaScript中的Window.location.href和Window.open()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆