我创建了http://www.ordinarypeopleofficial.com网站WordPress和主题“格莱姆”的套房优雅的主题。这个主题非常复杂。它大量使用JavaScript。它有700个代码行长的文件,名为custom.js,它使用AJAX管理整个网站。
由于这个原因,我无法包含JavaScript代码来将jPlayer加载到PHP脚本中,但我需要将其放入一个单独的JavaScript文件中,并从custom.js调用该文件。
在custom.js中,我在<head>标记中添加了以下行,其中包括名为chiama-player.js的文件:
var html_doc = document.getElementsByTagName('head').item(0);
var js = document.createElement('script');
js.setAttribute('language', 'javascript');
js.setAttribute('type', 'text/javascript');
js.setAttribute('src', "/wp-content/themes/Gleam/chiama-player.js");
html_doc.appendChild(js);名为chiama-player.js的文件包含实例化jPlayer的代码:
$(document).ready(function() {
if(window.location.href=="http://www.ordinarypeopleofficial.com/#!/le-canzoni/" || window.location.href=="http://www.ordinarypeopleofficial.com/le-canzoni/"){
$("#jp_container_1").css( { 'display': 'block' } );
$("#jquery_jplayer_1").jPlayer( {
ready: function () {
$(this).jPlayer("setMedia", {
m4a: "http://www.ordinarypeopleofficial.com/wp-content/themes/Gleam/shakeit.m4a",
});
},
swfPath: "http://www.ordinarypeopleofficial.com/wp-content/themes/Gleam/jplayer",
supplied: "m4a"
});
}
else{
$("#jp_container_1").css( { 'display': 'none' } );
}
});问题是:在支持M4A的浏览器上,一切都运行得很好。
问题就在Firefox上。火狐不支持M4A,所以它需要fallback才能工作。当我试图在火狐上加载页面时,我看到swfPath是正确识别的(实际上,如果我更改路径并键入一些随机文本,我就会在网络面板中看到404 )。
问题是,请求GET Jplayer.swf永远不会得到结果,并且在没有得到文件的情况下会持续加载几个小时。
发布于 2013-08-28 16:54:16
在文件custom.js中,在函数et_init_scripts()的末尾,我执行了以下步骤:
https://stackoverflow.com/questions/12546173
复制相似问题