我有这样的JavaScript块,它的种类从http://www.developphp.com/view.php?tid=1248被破解,我看到“undefined variable - broadcast”的错误。Javascript未定义变量函数之前
function cdtd(broadcast) {
/* expected date format is Month DD, YYYY HH:MM:SS */
var nextbroadcast = new Date(broadcast);
var now = new Date();
var timeDiff = nextbroadcast.getTime() - now.getTime();
if (timeDiff <= 0) {
clearTimeout(timer);
document.getElementById("countdown").innerHTML = "<a href=\"flconlineservices.php\">Internet broadcast in progress<\/a>";
/* Run any code needed for countdown completion here */
}
var seconds = Math.floor(timeDiff/1000);
var minutes = Math.floor(seconds/60);
var hours = Math.floor(minutes/60);
var days = Math.floor(hours/24);
hours %= 24;
minutes %= 60;
seconds %= 60;
document.getElementById("daysBox").innerHTML = days + " d";
document.getElementById("hoursBox").innerHTML = hours + " h";
document.getElementById("minsBox").innerHTML = minutes + " m";
// seconds isn't in our html code (javascript error if this isn't commented out)
/*document.getElementById("secsBox").innerHTML = seconds + " s";*/
var timer = setTimeout('cdtd(broadcast)',1000);
}
“”的页面会传递“广播”。 $ nextbroadcast基于用户查看页面的日期/时间。我想尝试var broadcast;
,var broadcast = "";
和var broadcast = null;
。每当我尝试在函数之前声明变量时,它就会中断脚本。
我做错了什么吗?脚本正在工作,很好,但我宁愿没有错误。
你试过周围的PHP去除引号? –
@AlexW我刚刚尝试删除引号,并打破了剧本。 – doubleJ