css如何跳转页面
本文小编为大家详细介绍“css如何跳转页面”,内容详细,步骤清晰,细节处理妥当,希望这篇“css如何跳转页面”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。
1、html实现
代码如下:
<head><!--以下方式只是刷新不跳转到其他页面--><metahttp-equiv="refresh"content="10"><!--以下方式定时转到其他页面--><metahttp-equiv="refresh"content="5;url=hello.html"></head>
对于这个方法我们实现会相对的比较简单,但是不足的点就是 Struts Tiles 中无法使用。
2、JavaScript实现
代码如下:
<scriptlanguage="javascript"type="text/javascript">//以下方式直接跳转window.location.href='hello.html';//以下方式定时跳转setTimeout("javascript:location.href='hello.html'",5000);</script>
通过使用JavaScript这个方法,它是属于比较灵活可以让我们结合更多其他功能的,但是有不足的是会受到不同浏览器的影响。
3、在firefox中结合倒数JavaScript实现
代码如下:
<scriptlanguage="javascript"type="text/javascript">varsecond=document.getElementById('totalSecond').textContent;setInterval("redirect()",1000);functionredirect(){document.getElementById('totalSecond').textContent=--second;if(second<0)location.href='hello.html';}</script>
4、解决Firefox不支持innerText的问题
代码如下所示:
<spanid="totalSecond">5</span><scriptlanguage="javascript"type="text/javascript">if(navigator.appName.indexOf("Explorer")>-1){document.getElementById('totalSecond').innerText="mytextinnerText";}else{document.getElementById('totalSecond').textContent="mytexttextContent";}</script>
5、整合
<spanid="totalSecond">5</span><scriptlanguage="javascript"type="text/javascript">varsecond=document.getElementById('totalSecond').textContent;if(navigator.appName.indexOf("Explorer")>-1){second=document.getElementById('totalSecond').innerText;}else{second=document.getElementById('totalSecond').textContent;}setInterval("redirect()",1000);functionredirect(){if(second<0){location.href='hello.html';}else{if(navigator.appName.indexOf("Explorer")>-1){document.getElementById('totalSecond').innerText=second--;}else{document.getElementById('totalSecond').textContent=second--;}}}</script>
小结:以上的例子都是主要来实现在五秒之后自动跳转到同一目录下的 hello.html文件中。
读到这里,这篇“css如何跳转页面”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注亿速云行业资讯频道。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。