<script>
function test(obj) {
var hour = (new Date).getHours();
if (hour>=7 && hour<18)
obj.href="a.html";
else
obj.href="b.html";
}
</script>
<a href="#" onclick="test(this)">test</a>
function test(obj) {
var hour = (new Date).getHours();
if (hour>=7 && hour<18)
obj.href="a.html";
else
obj.href="b.html";
}
</script>
<a href="#" onclick="test(this)">test</a>
function test(obj) {
var hour = (new Date).getHours();
if (hour>=7 && hour<=18)
obj.href="a.html";
else
obj.href="b.html";
}
</script>
<a href="#" onclick="test(this)">test</a>
<script>
var nh = new Date().getHours();
switch(nh){
case 1:window.location="http://www.sina.com.cn";break;
case 2:window.location="http://www.sohu.com";break;
case 3:window.location="http://www.163.com";break;
case 4:window.location="http://www.csdn.net";break;
//case 其他的小时;
default:window.location="http://www.jxxg.com";break;
}
</script>
<!--
function automaticRedirectByTime(){
var currentTime = new Date();
var numHour = currentTime.getHours(); var strTargetPage = "b.html";
if (numHour>=7 && numHour<18)
{
strTargetPage = "a.html";
} if (document.location.href.indexOf(strTargetPage) == -1)
{
document.location.href = strTargetPage;
}}
//-->
</script>
</head>
<body onload="automaticRedirectByTime();">
</body>