HTML五类方法实现页面跳转

xiaoxiao2021-02-28  159

1. meta标签

<meta http-equiv="refresh" content = "5;url = index.php"> #5秒后自动跳转

2. window.location+其他标签

<script language = 'javascript' type = 'text/javascript'> function skip(){ window.location = "index.php"; } </script> <button onclick = "window.location='test1.php'" >skip</button> <head> <script type="text/javascript"> document.location="index.php"; </script> </head> #自动跳转 <script type=text/javascript> setTimeout("javascrfipt.location.href='index.php'",5000) </script> #5秒后自动跳转

3. a标签/a标签+其他标签

<a href="index.php">skip</a> <a href='index.php'><button>skip</button></a>

a标签的text-decoration:none,可以用来取消链接下面的下划线

4. history.back(-1)

<script type="text/javascript"> function skip(){ history.back(-1); } </script>

5.window.navigate(index.php)

<script type="text/javascript"> function skip(){ window.navigate("index.php"); } </script> #只适用于IE

拓展

window: 浏览器会为每一个打开的html创建对应的html对象,如果这个文档包含了多个框架,则浏览器会为原始文档创建一个window对象,再为每一个框架创建额外的window对象。 location: 该对象包含当前url信息,拥有多个属性。默认使用href,表示整个url。 location=”index.php”就相当于window.location.href=”index.php”

转载请注明原文地址: https://www.6miu.com/read-20870.html

最新回复(0)