window.location和window.open做链接的区别

window.location和window.open做链接的区别

一、性质不同

1、window.location:window.location是window对象的属性。

2、window.open:window.open是window对象的方法。

二、用途不同

1、window.location:window.location用来替换当前页,也就是重新定位当前页 。

2、window.open:window.open用来让链接页面在窗口中打开。

三、打开网站不同

1、window.location:window.location只能在一个网站中打开本网站的网页。

2、window.open:window.open可以在一个网站上打开另外的一个网站的地址 。

四、语法

1、window.location:

2、window.open:

window.open(URL,name,specs,replace)

 

原文地址:https://www.cnblogs.com/Michelle20180227/p/12599545.html