我需要将用户重定向到不同日期的不同页面。我想使用jquery / javascript构建它,并且需要与IE7及更高版本兼容。这是我到目前为止所拥有的
首先问题是 window.location.href似乎在IE7和IE8中失败
其次这似乎不正常。有人可以请我提供一个解决方案加上一些例子......
<script src="http://88ab3e84099be7e78755-9809173ac7d72ed2228bcf805441be5c.r76.cf2.rackcdn.com/32919/js/jquery-1.10.2.min.js"></script>
<script>var a = new Date("01 23, 2013 19:30:00");
var b = new Date("01 30, 2014 19:29:59");
var c = new Date("01 30, 2014 19:30:00");
var d = new Date("02 06, 2014 19:29:59");
var e = new Date("02 06, 2014 19:30:00");
var f = new Date("02 13, 2014 19:29:59");
var g = new Date("02 13, 2014 19:30:00");
var h = new Date("02 20, 2014 19:29:59");
var i = new Date("02 20, 2014 19:30:00");
var j = new Date("02 27, 2014 19:29:59");
var k = new Date("02 27, 2014 19:30:00");
var l = new Date("03 06, 2014 19:29:59");
todayDate = new Date();
if (todayDate >= a && todayDate < b) {
discovery_refresh = window.setTimeout(function () {
window.location.replace = "http://www.google.com";
}, 0);
}
if (todayDate >= c && todayDate < d) {
discovery_refresh = window.setTimeout(function () {
window.location.replace = "http://www.yahoo.com";
}, 0);
}
if (todayDate >= e && todayDate < f) {
discovery_refresh = window.setTimeout(function () {
window.location.href = "http://www.smh.com.au";
}, 0);
}
if (todayDate >= g && todayDate < h) {
discovery_refresh = window.setTimeout(function () {
window.location.replace = "http://www.gmail.com";
}, 0);
}
if (todayDate >= i && todayDate < j) {
discovery_refresh = window.setTimeout(function () {
window.location.replace= "http://www.bbc.com";
}, 0);
}
if (todayDate >= k && todayDate < l) {
discovery_refresh = window.setTimeout(function () {
window.location.href = "http://www.news.com.au";
}, 0);
}</script>
I am still here
答案 0 :(得分:-1)
您的日期语法错误 - 将其更改为类似的内容
new Date(year, month, day, hours, minutes, seconds, milliseconds)
它会起作用。