我知道还有其他与堆栈溢出相关的类似问题,但似乎没有一个可以纠正我的问题。每个浏览器都会出现此错误(尽管我使用了 webkit 错误名称)。
我需要使用 PHP 添加 javascript。这会导致出现“意外令牌非法”错误。我尝试了这个答案但没有成功。这就是我现在拥有的:
$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>