doutinghou6980 2014-03-16 17:11
浏览 69

HTML5视频标签:Onclick PHP函数无法访问JavaScript:转义字符串

I call a function from the "onclick" of a HTML5 video tag inside PHP-

      $txt= $row['location'];
      $ext="openFancyBox($txt)";
     <video id="thumbnail" onclick="'.$ext.'" width="320" height="240" controls>

The location information I send to the javascript function takes the following format (on inspect element):

     onclick="openFancyBox(photos/2014.02.031391434118.mp4)"

It never gets into the javascript function, the error from inspect element states-

  Uncaught SyntaxError: Unexpected number

I think this is because it is expecting a string format? The file name has to remain this random format.

  • 写回答

1条回答 默认 最新

  • doutao1171 2014-03-16 17:13
    关注

    You're missing the code to make the location a string in the JavaScript code. Try this:

    $ext='openFancyBox("' . $txt . '")';
    
    评论

报告相同问题?