JavaScript,js

js链接跳转

location.assign(“http://www.baidu.com”);

location.href=”http://www.baidu.com”;

这两者一样,会产生历史记录,点击后退有效。

location.replace(“http://www.baidu.com”);

指定URL代替当前文档,不会产生历史记录,无法后退。

<input type=”button” value=”返回” οnclick=”window.location=’你要转向的页面'”>
<input type=”button” value=”返回” οnclick=”window.location.href=’你要转向的页面'”>
<input type=”button” value=”返回” οnclick=javascript:location.href=’你要转向的页面’>

<button type=”button” onclick=”document.location.href=’/'”>返回首页</button>

return false:取消默认的事件行为,例如你给a标签增加了href,就会既执行函数也会跳转


First

第一个推荐位

 

使用 window.open 跳转,语法:window.open(*URL,name,specs,replace*) 参考文档,如下代码所示
https://www.runoob.com/jsref/met-win-open.html


First

第一个推荐位

_self:代表在当前窗口打开,默认是 _blank,在新页面打开。

Collection

一条

2020-4-30 15:56:50

Collection

三不

2020-8-23 21:03:16