2011-01-20 5 views
0
코드는 PHP 부에
$var = <<<MY_MARKER 
<script type="text/javascript"> 
    function asso(){ 
    showSpoiler("assoluto"); 
    var x = document.getElementById("assoluto"); 
    x.write('$str'); 
} 
</script> 
MY_MARKER; 

echo $var; 

,이 PHP 시스템에서 valuted 코드이다 : X의 라인 ILLEGAL 불필요한 토큰 : 콘솔에서 오류가 처리되지 않는 구문 에러가document.write를 문제

<script type="text/javascript"> 

    function asso(){ 

     showSpoiler("assoluto"); 

     var x = document.getElementById("assoluto"); 

     x.write('<div id="log" style="position:absolute;right:0;left:0;top:0;background:black;height:10px;"> 
<form action="/myblog/index.php" method="POST"> 
<fieldset> 
<legend>Login:</legend> 
<label><input name="username" size="9" maxlength="15" type="text" value="username"></label> 
<label><input name="password" size="9" maxlength="15" type="password" value=""></label> 
<label><input name="submit" type="submit" value="Login"></label> 
<label><u><a href="index.php?pag=5">Registrati</a></u></label> 
</fieldset> 
</form> 
</div> 
'); 

    } 

</script> 

인 .쓰다(.....);

+0

어디에서 함수를 호출합니까? – bharath

+0

구체적으로 무엇이 고장 났는지 알아낼 때까지 코드를 자르려고 했습니까? –

+0

@bharath 전화 기능은 ... ... – Gio

답변

2

자바 스크립트에서 여러 줄 문자는 허용되지 않습니다. 마다 "\ n"문자 제거하려고 :

$str = str_replace(array("\t","\n","\r"), "", $str); 

x.innerHTML = '$ str을'너무

$str = str_replace("\n","",$str); 
+0

같은 문제가 생겼습니다. $ str = str_replace (array ("\ t", "\ n"), "", $ str); 나는 문제가 자바 스크립트에 관한 것이라고 생각한다. – Gio