私は現在、jQueryとプラグインをフッターに配置するhtml5ボイラープレートを使用しています。唯一の問題は、すべてのページで同じfooter.phpファイルを使用していることです。プラグインがまだロードされていない場合、ページ固有の関数を含めるにはどうすればよいですか?つまり
<?php include_layout_template('header.php', '../');?>
<div id='mediaspace'>This text will be replaced</div>
<!-- Video for this page: -->
<script type='text/javascript'>
jwplayer('mediaspace').setup({
'flashplayer': '../resources/player.swf',
'file': 'http://content.longtailvideo.com/videos/flvplayer.flv',
'controlbar': 'bottom',
'width': '470',
'height': '320'
});
</script>
<?php //This file has the jwplayer function in it:
include_layout_template('footer.php', '../'); ?>
これを行うと私は得ます
Uncaught ReferenceError: jwplayer is not defined
プラグインインクルードをヘッダーに入れる方が簡単になるでしょうか?人々は通常、最後に定型文/読み込みスクリプトでこのようなことにどのように取り組んでいますか?