我知道還有其他類似的問題與堆棧溢出有關,但沒有一個似乎糾正我的問題。每個瀏覽器都會發生此錯誤(儘管我使用了webkit錯誤名稱)。意外令牌非法
我需要使用PHP添加JavaScript。這會導致出現錯誤「Unexpected token illegal」。我試過answer沒有成功。這是我現在有:
$texte .="<script>";
$texte .="$(function(){";
$texte .="$('#field_".$this->id."').css('position','absolute').css('left','".$this->x."px').css('top','".$this->y."px');";
$texte .="$('#field_".$this->id."').draggable({stop:function(event,ui){saveFieldPosition(".$this->id.");},grid:[10,10],containment:\".work_plane:first\"}).resizable({grid:[10,10]});";
$texte .="});";
$texte .="</script>";
return $texte;
我已經啓用Dreamweaver中的隱藏字符,並刪除每一個會在$ texte值。
有人看到問題嗎?任何暗示將不勝感激。
編輯:$ texte在添加之前通過htmlentities()傳遞。
下面是輸出:
<script>$(function(){$('#field_1').css('position','absolute').css('left','px').css('top','px');$('#field_').draggable({stop:function(event,ui){saveFieldPosition();},grid:[10,10],containment:".work_plane:first"}).resizable({grid:[10,10]});});</script>
您可以使用源代碼在頁面加載後出現的內容更新您的問題嗎?如果對其中的某些對象屬性未定義,那麼將無法從您發佈的內容中知道這些信息。 – 2012-07-31 19:10:38
您可以包含php處理後評估的代碼嗎? – Wug 2012-07-31 19:10:43
你想達到什麼目的? – codingbiz 2012-07-31 19:11:48