我知道还有其他类似的问题与堆栈溢出有关,但没有一个似乎纠正我的问题。每个浏览器都会发生此错误(尽管我使用了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