在php中回显javascript函数

时间:2018-01-29 10:55:57

标签: javascript php

我无法使用以下javascript链接调用javascript函数。这里有什么问题请有人帮我。

$buttonMessage = '

 <a class="drupalchat-profile-un drupalchat_cng" 
 href="javascript:void(0)"    
 onclick="javascript:chatWith('.$pUsername.','.$profile_uid.','.$UserAvatar.','.$onof.')">  
 </a>'; 

1 个答案:

答案 0 :(得分:3)

您可能有一些JS错误,需要在您的值周围添加单引号:

$buttonMessage = '

 <a class="drupalchat-profile-un drupalchat_cng" 
 href="javascript:void(0)"    
 onclick="javascript:chatWith(\''.$pUsername.'\',\''.$profile_uid.'\',\''.$UserAvatar.'\',\''.$onof.'\')">  
 </a>';