在制作网站的时候我们很多时候都会遇到使用javascript来控制跳转链接。

JS跳转链接有很多种这里就写一些咱们经常用的到的方法:

第一种,JS直接打开页面(不删除来源页面)(www.gendan5.com)

window.location.href="http://cenggel.com/";
第三种,直接打开页面(删除来源页面)

window.location.replace("http://cenggel.com/");

第四种,固定位置打开

top.location='http://cenggel.com/';//在顶层页面打开url(跳出框架)
self.location='http://cenggel.com/';//仅在本页面打开url地址
parent.location='http://cenggel.com/';//在父窗口打开Url地址

第五种,返回前进页面

window.history.back(-1);
window.history.go(-1);

第六种,meta跳转页面(这个不算JS的,单独拿出来有点少就放这里吧)

<meta http-equiv=refresh content=5; URL="http://cenggel.com/">

当然这个JS的链接方式还有很多的扩展属性,但是上面的方法也够咱们使用了。

后期我会对一些参数和方法进行解释。