HTML如何做301跳转

HTML如何做301跳转,第1张

html是做不了301跳转的,但是可以通过

在5秒后,自动跳转到同目录下的hello.html(根据自己需要自行修改)文件。

下面列了五个例子来详细说明,这几个例子的主要功能是:在5秒后,自动跳转到同目录下的hello.html(根据自己需要自行修改)文件。

1)

html的实现

<head>

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

-->

<meta http-equiv="refresh"

content="10">

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

-->

<meta http-equiv="refresh"

content="5url=hello.html">

</head>

优点:简单

缺点:Struts Tiles中无法使用

2)

javascript的实现

<script

language="javascript"

type="text/javascript">

// 以下方式直接跳转

window.location.href='hello.html'

// 以下方式定时跳转

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

5000)

</script>

优点:灵活,可以结合更多的其他功能

缺点:受到不同浏览器的影响

3)

<script

language="javascript"

type="text/javascript">

var second =

document.getElementByIdx_x('totalSecond').textContent

setInterval("redirect()", 1000)

function redirect()

{

document.getElementByIdx_x('totalSecond').textContent = --second

if (second < 0) location.href

= 'hello.html'

}

</script>

参考我回复其他人的页面:http://zhidao.baidu.com/question/1882892067218382988

<div style="width:301pxfloat:left">

<div style="float:leftwidth:50pxheight:23pxborder:1px solid #CC3300cursor:pointer" onclick="changeDiv('1','2')">按钮1</div>

<div style="float:leftmargin-left:3pxwidth:50pxheight:23pxborder:1px solid #CC3300cursor:pointer" onclick="changeDiv('2','1')">按钮2</div>

<div style="float:leftwidth:300pxborder:1px solid #CC3300height:100pxmargin-top:5px" id="div1">

按钮1按钮1按钮1按钮1按钮1按钮1按钮1按钮1按钮1按钮1按钮1按钮1按钮1按钮1按钮1内容

</div>

<div style="float:leftwidth:300pxborder:1px solid #CC3300height:100pxmargin-top:5pxdisplay:none" id="div2">

按钮2按钮2按钮2按钮2按钮2按钮2按钮2按钮2按钮2按钮2按钮2按钮2按钮2按钮2按钮2按钮2按钮2按钮2内容

</div>

</div>

<script type="text/javascript">

function changeDiv(blockid,noneid){

document.getElementById("div"+blockid).style.display = "block"

document.getElementById("div"+noneid).style.display = "none"

}

</script>


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

原文地址: https://www.outofmemory.cn/zaji/6174025.html

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

发表评论

登录后才能评论

评论列表(0条)

保存