返回到上一页的html代码的几种写法

返回到上一页的html代码的几种写法,第1张

返回到上一页的html代码的几种写法

1.超链接返回上一页代码:

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

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

2.用按钮代码:

<input type=”button” name=”Submit” onclick=”javascript:history.back(-1)” value=”返回上一页”>

3.图片代码:

<a href=”javascript :” onClick=”javascript :history.back(-1)”><img src=”图片路径” border=”0″ title=”返回上一页”></a>

[color=#FF0000]几秒钟后[/color]自动返回上一页代码:(加入两个head间,3000表示3秒)

<SCRIPT language=javascript>

function go()

{

window.history.go(-1)

}

setTimeout(“go()”,3000)

</SCRIPT>

“>返回上一页</a>

<script>alert(‘发布失败’)location.href=’index.php’window.history.go(-1)

</script>

扩展资料:

跳转页面的html代码的几种写法

html的实现

<head>

<!-- 以下方式只是刷新不跳转到其他页面 -->

<meta http-equiv="refresh" content="10">

<!-- 以下方式定时转到其他页面 -->

<meta http-equiv="refresh" content="5url=hello.html">

</head>

2. javascript的实现

<script language="javascript" type="text/javascript">

// 以下方式直接跳转

window.location.href='hello.html'

// 以下方式定时跳转

setTimeout("javascript:location.href='hello.html'", 5000)

</script>

3.结合了倒数的javascript实现(IE)

<span id="totalSecond">5</span>

<script language="javascript" type="text/javascript">

var second = totalSecond.innerText

setInterval("redirect()", 1000)

function redirect(){

totalSecond.innerText=--second

if(second<0) location.href='hello.html'

}

</script>

参考资料:百度百科-html代码

window.parent.location.href='b页面地址'

可以在b页面载入的时候加入刷新 *** 作,window.location.reload()或者history.go(0);

返回上一页是history.go(-1);

一般页面会自动刷新的,所以上面的window.location.href=''就可以解决。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/zaji/7072320.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-01
下一篇2023-04-01

发表评论

登录后才能评论

评论列表(0条)

    保存