javascript怎么通过按钮跳转跳转新页面

JavaScript09

javascript怎么通过按钮跳转跳转新页面,第1张

按钮添加点击事件 然后在点击事件中利用js跳转

JS跳转大概有以下几种方式:

第一种:(跳转到b.html)

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

window.location.href="b.html"

</script>

第二种:(返回上一页面)

<script language="javascript">

window.history.back(-1)

</script>

第三种:

<script language="javascript">

window.navigate("b.html")

</script>

第四种:

<script language="JavaScript">

self.location=’b.html’

</script>

第五种:

<script language="javascript">

top.location=’b.html’

</script>

javascript中的location.href有很多种用法,主要如下:

self.location.href="/url" 当前页面打开URL页面

location.href="/url" 当前页面打开URL页面

windows.location.href="/url" 当前页面打开URL页面,前面三个用法相同

this.location.href="/url" 当前页面打开URL页面

parent.location.href="/url" 在父页面打开新页面

top.location.href="/url" 在顶层页面打开新页面