C에서이 코드 예제를 사용하여 위의 오류가 발생했습니다. 사용 된 함수는 src.js에 있습니다. 나는 웹 UI를로드 할 때 오류가 잘 된 SomeFuncion()하지만 anotherFunction()에 대한 작품 팝업 :Onload not working : 잡히지 않은 참조 오류, 정의되지 않은 함수
fprintf(out, "<script type='text/javascript' src='/src.js'></script>\n");
fprintf(out, "<body onload=\"someFunction()\">\n");
fprintf(out, "<button type='button' id='CheckButton' onclick='anotherFunction()'>Check</button></br>");
src.js :
var check = 0;
function someFunction()
{
req=new XMLHttpRequest();
req.onreadystatechange=yetAnotherFunction;
req.open("GET","xxx",true);
req.send();
setTimeout("someFunction()", 3000);
}
function anotherFunction()
{
if (!check) {
check = 1;
setButtonText('CheckButton', 'Stop Checking');
someFunction();
} else {
check = 0;
setButtonText('CheckButton', 'Checking');
}
}
가 난 할 노력하고있어하면 제거입니다 버튼을 클릭하고 onload 기능으로 바꿉니다. 누구든지이 코드의 문제점을 알고 있습니까?
무엇이'function()'입니까? –
function()이 src.js에 정의되어 있는지 확인하십시오. src.js가 html과 동일한 디렉토리에 있으면 src = "src.js"만 사용하십시오. – Ollaw
'function'은 예약어입니다. 당신은'function'이라는 함수를 가질 수 없습니다. – rustyx