我正在使用html5樣板,它將jQuery和您的插件放入頁腳。唯一的問題是,我在每個頁面中使用相同的footer.php文件。如果插件尚未加載,我該如何處理包含特定於頁面的功能?即頁腳中的JavaScript函數
<?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
是不是會更容易只是把插件包含在頭?人們通常最終如何在樣板/加載腳本中解決這樣的問題?
難道你不能把你的jwplayer-invocation-script放在頁腳之後嗎? – Bergi