我们想隐藏我们的内容,直到某一天的午夜;在那之后,我们想将 iframe 显示为某种形式。如何做到这一点?我想知道您是否会结合使用 jQuery 倒计时插件?
问问题
101 次
2 回答
0
唯一合适的解决方案是检查服务器端,因为任何带有计时器的东西都可以在客户端(相对)轻松地进行操作。
它应该类似于以下内容(伪代码):
服务器端脚本:
// normal stuff
if (servertime == your desired time){
// include the special codez
// It's probably best to have that iframe content in a separate file
// and just import the file here
}
// more normal stuff
于 2013-01-17T13:30:09.910 回答
0
做客户端并没有对用户隐藏太多......
但这是一个非常基本的算法,我在这里写客户端..你可以使用javascript的`settimeout()'...
function TestTime(reqTime) {
var date=new Date();
if(date.getHours()===reqTime.getHours() && date.getMinutes()===reqTime.getMinutes()) { // you may need to add other validations like date etc
//on success either redirect to other page or show the hidden content
location.href=""//the redirected page may need to validate on server side
$('div').show() // show content
} else {
$('div').html('Some content'); //you can show counter kind of thing here
window.setTimeout(TestTime, 1000, true);
}
}
于 2013-01-17T13:37:16.737 回答