1.3秒後に自動的に戻ります
コードコピーは次のとおりです。
<span id = "totalsecond"> 3 </span> 3秒後に自動的に戻ります
<スクリプト言語= "javascript" type = "text/javascript">
<! -
var second = document.getElementById( 'TotalSecond')。textContent;
if(navigator.appname.indexof( "explorer")> -1)//それがIEブラウザかFirefoxブラウザかを判断し、対応する測定値を使用して秒数を取得する
{
second = document.getElementByID( 'TotalSecond')。innertext;
} それ以外
{
second = document.getElementByID( 'TotalSecond')。textContent;
}
setInterval( "redirect()"、1000);
function redirect()
{
if(second <0)
{
location.href = 'http://www.baidu.com';
} それ以外
{
if(navigator.appname.indexof( "explorer")> -1)
{
document.getElementById( 'TotalSecond')。innertext = second-;
} それ以外
{
document.getElementById( 'TotalSecond')。textContent = second--;
}
}
}
- >
</script>