2013-12-18 2 views
-1

다른 사람이 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

을 * 편집 *

나는 당신의 응답에 따라 코드를 업데이트했는데 내가 ' 여전히 페이지를로드하는 부분에 문제가 있습니다. 그 부분을 변경하고 경고를 추가 했으므로 PHP 페이지에 아무런 문제가 없는지 확인할 수는 있지만 경고 표시가 나타나지 않습니다. 교체 document.clock.stwa.value = sec;

document.clock.stwa.value = parseInt(sec);

3 - -

<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> 
+3

백색 페이지는 JS 에러 때문일 수있다. 브라우저 콘솔에 무엇이 표시됩니까? – isherwood

+0

잡히지 않은 ReferenceError : $이 (가) 정의되지 않았습니다. popup.js : 1 리소스를로드하지 못했습니다. http://box.anchorfree.net/insert/41.js?v=413161526 잡히지 않은 TypeError : 정의되지 않은 속성 'stwa'을 읽을 수 없습니다. –

+2

jquery가 페이지에 링크되어 있지 않음 –

답변

-1

1 - 페이지

2 링크 jQuery를 교체 SD = window.setTimeout("stopwatch();", 1000);

SD = window.setTimeout(stopwatch(), 1000);

4 - 모든 입력이 같은 ID 'stwa'및 형태 '시계'내부 'theButton'로 정의되는 경우 HTML 체크인 :

<form name="clock"> 
    <input type="text" id="stwa" name="stwa" value="00" /> 
    <input type="button" id="theButton" name="theButton" value="" /> 
</form> 
관련 문제