Code tự động chuyển trang bằng script

0
1953

<html>
<title> Tự động chuyển trang </title>
<head>

<script type=”text/javascript”>
var time = 5; // Thời gian chuyển
var page = “https://vannamit.com/”; //Trang web cần chuyển
function countDown(){
time–;
gett(“container”).innerHTML = time;
if(time == -1){
window.location = page;
}
}
function gett(id){
if(document.getElementById) return document.getElementById(id);
if(document.all) return document.all.id;
if(document.layers) return document.layers.id;
if(window.opera) return window.opera.id;
}
function init(){
if(gett(‘container’)){
setInterval(countDown, 1000);
gett(“container”).innerHTML = time;
}
else{
setTimeout(init, 50);
}
}
document.onload = init();
</SCRIPT>
</head>
<body>

<h4>Chuyển trang sau <span id=”container”></span> (giây)!</h4>

</body>
</html>