HTML页面跳转的5种方法 |
您所在的位置:网站首页 › 跳转按钮列表 › HTML页面跳转的5种方法 |
下面列了五个例子来详细说明,这几个例子的主要功能是:在5秒后,自动跳转到同目录下的hello.html(根据自己需要自行修改)文件。 1) html的实现 优点:简单缺点:Struts Tiles中无法使用 2) javascript的实现 // 以下方式直接跳转 window.location.href='hello.html'; // 以下方式定时跳转 setTimeout("javascript:location.href='hello.html'", 5000);优点:灵活,可以结合更多的其他功能缺点:受到不同浏览器的影响 3) 结合了倒数的javascript实现(IE) 5 var second = totalSecond.innerText; setInterval("redirect()", 1000); function redirect(){ totalSecond.innerText=--second; if(second -1) { second = document.getElementById('totalSecond').innerText; } else { second = document.getElementById('totalSecond').textContent; } setInterval("redirect()", 1000); function redirect() { 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--; } } }看完点个赞吧!想加入的伙伴给我留言或者直接私信。 作者:ala617784513 链接:HTML页面跳转的5种方法 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |