网站url返回上一页代码大全javascript

1、文字链接:

<a href=”javascript:history.back(-1)”>返回上一页</a>

 

2、图片链接:

<a href=”javascript:history.back(-1)” target=”_self”><img src=”http://localhost/host/logo.png” /></a>

 

弹出提示,返回上一页:

<script>alert(“恭喜您,操作成功!”); window.history.back(-1); </script>

 

3、过几秒中后返回到上一页:

<script language=”JavaScript”> setTimeout(“history.go(-1)”,3000) </script>  //方法一,此法不刷新原历史网页

<meta http-equiv=”refresh” content=”3;url=<?php echo $_SERVER[‘HTTP_REFERER’]?>”>   //方法二,适用于php,返回上一页并刷新

 

4、直接跳转

<script>window.location.href=’http://localhost/host/’;</script>