我有这个小脚本,假设有人已经播放了超过27秒的音频文件,可以对表进行+1。脚本变成白色页
用于正常工作的代码,直到我的主机被黑客入侵,我的代码被混淆。
现在我不知道它有什么问题。
我不擅长jQuery。我查阅了一些教程并做了大量的猜测,所以我可以得到这段代码的工作。
$(document).ready(function() {
$("#audio").bind('play', function() {
document.clock.theButton.value = "Stop";
stopwatch(this.value);
});
$("#audio").bind('pause', function() {
document.clock.theButton.value = "Start";
});
});
var sec = -1;
function stopwatch(text) {
sec++;
if (sec <= 9) {
sec = "0" + sec;
}
document.clock.stwa.value = sec;
if (document.clock.stwa.value == "27") {
$("#play").load("<?php echo 'accounts.php?id={$id}&music={$music}&add_play=1'; ?>");
}
if (document.clock.theButton.value == "Start") {
window.clearTimeout(SD);
sec = sec - 1;
return true;
}
SD = window.setTimeout("stopwatch();", 1000);
}
$(document).ready(function() {
$("#audio").bind('ended', function() {
sec = -1;
});
});
,我发现了以下错误:
Uncaught ReferenceError: $ is not defined popup.js:1 Failed to load resource box.anchorfree.net/insert/41.js?v=413161526
Uncaught TypeError: Cannot read property 'stwa' of undefined
*编辑*
我已经按照你的反应更新的代码和我” m仍然有问题,它的部分是假设加载页面。我已经改变了这部分,并添加了一个警告,所以我可以确保没有错误的PHP页面,但我甚至没有得到警报显示。
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
<script language="JavaScript" type="text/javascript">
$(document).ready(function(){
$("#audio").bind('play', function(){
document.clock.theButton.value = "Stop";
stopwatch(this.value);
});
$("#audio").bind('pause', function(){
document.clock.theButton.value = "Start";
});
});
var sec = -1;
function stopwatch(text) {
sec++;
if (sec<=9) { sec = 0 + sec; }
document.clock.stwa.value = sec;
if(document.clock.stwa.value=="27"){
alert("Worked");
}
if (document.clock.theButton.value == "Start") {
window.clearTimeout(SD);
sec=sec-1;
return true; }
SD = window.setTimeout(stopwatch, 1000);
}
$(document).ready(function(){
$("#audio").bind('ended', function(){
sec=-1;
});
});
</script>
<form name="clock" style="display:none;"><br />
<input type="text" size="12" name="stwa" id="stwa" /><br />
<input type="button" name="theButton" onClick="stopwatch(this.value);" value="Start" />
<input type="button" value="Reset" onClick="resetIt();reset();" />
</form>
白色页面可能是由于一个JS错误。浏览器控制台中显示了什么? – isherwood
Uncaught ReferenceError:$未定义popup.js:1 未能加载资源http://box.anchorfree.net/insert/41.js?v=413161526 未捕获TypeError:无法读取未定义的属性'stwa' –
jquery没有链接到页面 –