将Javascript插入PHP工作表


Insert Javascript to PHP sheet

你好,我必须为Nextgen Gallery Slider Widget PHP输出之一实现一个jquery任务。至少我意识到,由于我的经历,我被困在了一个荒无人烟的地方。有人能帮我吗

$output .= "'n<script type='"text/javascript'">";
$output .= "'n  jQuery(window).load(function() {";                
// Shuffle results on random order so even if page is cached the order will be different each time
if($order == 'random' && $shuffle == 'true')
{
  $output .= "'n    jQuery('div#" . $html_id . "').jj_ngg_shuffle();";
}
$output .= "'n    jQuery('div#" . $html_id . "').nivoSlider(";
if(count($javascript_args) > 0)
{
  $output .= "{" . implode(",", $javascript_args) . "}";
}
$output .= ");";
if($has_control_nav && $has_thumbs)
{
  if($controlnavthumbs == 'nextgen_thumbs' || $controlnavthumbs == 'nextgen_original')
  {
    $output .= "'n    JJNGGUtils.wordpressThumbs('" . $html_id . "', " . ($controlnavthumbs == 'nextgen_thumbs' ? 'true' : 'false') . ");";
  }
  if($has_center && $thumbsgap != '')
  {
    $output .= "'n    JJNGGUtils.wordpressThumbsCenterFix('" . $html_id . "');";
  }
  $output .= "'n    jQuery('div#" . $html_id . " div.nivo-controlNav').css('visibility', 'visible');";
}
$output .= "'n  });";  
$output .= "'n</script>'n";
if($shortcode != '1')
{
  echo $before_widget . "'n<ul class='"ul_jj_slider'">'n    <li class='"li_jj_slider'">" . $output . "'n    </li>'n  </ul>'n" . $after_widget;     
}
else
{
  echo $output;
}

}

我想添加

    <script type="text/javascript">
jQuery(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
  jQuery('#slider').css({visibility: "hidden"});
 // toggles the slickbox on clicking the noted link
  jQuery('a.nivo-controlNav').click(function() {
    jQuery('#slider').css({visibility: "visibile"});
    return false;
  });
});
</script>

非常感谢您的任何提示和帮助

使用PHP Heredoc功能可以实现您想要的东西,这里有一个关于Heredoc及其用法的简单教程检查一下。您只需要将消息替换为JS代码。你完了。