简体   繁体   English

首次调用onclick时未调用javascript函数

[英]javascript function is not invoked at the first time onclick

I have a following code: 我有以下代码:

$this->content->text  .=
         '<div id="gv_block_div">
            <a href="javascript:void(0)" onclick="pop('.htmlspecialchars($jsonObject).', \''.$root.'\', '.$userid.')">Click Here</a> 
         </div>';  

return $this->content;   

When I login and click "Click Here" the onclick event doesn't trigger. 当我登录并单击“单击此处”时,onclick事件不会触发。 It works at the second click. 第二次单击即可使用。 However, after that (before logging out), single click works just fine. 但是,此后(注销之前),单击即可正常工作。

What should be the potential problem? 潜在的问题应该是什么?

try <a href="#" onclick="return pop('.htmlspecialchars($jsonObject).', \\''.$root.'\\', '.$userid.')">Click Here</a> and then , return false; 尝试<a href="#" onclick="return pop('.htmlspecialchars($jsonObject).', \\''.$root.'\\', '.$userid.')">Click Here</a>然后返回false; in the pop() function , or wrap it in an other function that returns false. 在pop()函数中,或将其包装在另一个返回false的函数中。 that might do the trick. 这可能会解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM