Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Java EE (J2EE) и Spring > Redirect через пять секунд


Автор: sith 27.9.2007, 11:46
... такая вот задача... сервлет возвращает страничку... а через пять секунд должен сдлеать редирект на другую

Автор: Бонифаций 27.9.2007, 11:56
В head страницы

Код

<meta http-equiv="Refresh" content="5; URL=http://www.new.site/page.html">

Автор: Vasay 27.9.2007, 12:32
Или через JavaScript.

Код

<script LANGAUGE="JAVASCRIPT 1.3"
    TYPE="text/javascript">
    <!--
    // редирект через 5 сек.
    var URL = "1.html"
    var speed = 5000
    function reload() {
    location = URL
    }
    setTimeout("reload()", speed);
    //-->
    </script>


Можно с отображением таймера:
Код

<html>
<body>
<p><form name="redirect">
<center>
<font face="Arial"><b>You will be redirected to the script in<br><br>
<form>
<input type="text" size="3" name="redirect2">
</form>
seconds</b></font>
</center>
<script>
<!--
//change below target URL to your own
var targetURL="../index.html"
//change the second to start counting down from
var countdownfrom=5
var currentsecond=document.redirect.redirect2.value=countdownfrom+1
function countredirect(){
if (currentsecond!=1){
currentsecond-=1
document.redirect.redirect2.value=currentsecond
}
else{
window.location=targetURL
return
}
setTimeout("countredirect()",1000)
}
countredirect()
//-->
</script>

</div>
</body>
</html>

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)