This article describes the method of using php code in JavaScript. Share it for your reference. The specific implementation method is as follows:
The code copy is as follows:
<script type="text/javascript" >
<?php if (!empty($searchResult)):?>
$.searchModule.init({display:<?php echo MAX_KEYWORDS_DISPLAY_COUNT; ?>,
mode:<?php echo $searchResult->mode; ?>,
query:'<?php echo (isset($keyword_assistant)?$keyword_queries:$keyword); ?>'});
$(document).ready(function(){
<?php if (isset($scroll_pos)): ?>
$(this).scrollTop(<?php echo $scroll_pos; ?>);
<?php endif; ?>
$.searchModule.checkSearchStatsRequest();
});
<?php else:?>
$.searchModule.init();
<?php endif;?>
</script>
I hope this article will be helpful to everyone's JavaScript programming.