Skip to main content
 首页 » 编程设计

jquery之jPlayer 在 chrome 上停止调用 jQuery.load() 方法刷新内容,但在 Firefox 上工作

2026年07月28日7zfyouxi

我正在使用 jPlayer 来播放音频。我们需要比赛不间断。为此,我们使用 jQuery.load() 方法加载页面内容并替换页面上的内容。

我们不会以任何方式刷新 jPlayer 内容。

该代码在 Firefox 中运行良好,并且 jPlayer 可以不间断地播放音频。但在 chrome 和 safari 上,jPlayer 会在执行完 jquery load 方法后停止并重新启动。

此外,当我在本地计算机上运行代码时,它们在任何浏览器中都不会中断。仅当我在服务器上运行代码时,它们才会中断。

我们需要不间断的音乐。

我的代码如下:

function loadContent(pagePath) { 
    //Method called on menu click to load content without page refresh 
    //Loading the said page (pagePath - relative path of page) 
    jQuery('#containerDiv').fadeOut(200, function() { 
    jQuery('#waitingDiv').show(); 
        jQuery(this).empty(); 
        jQuery(this).load(pagePath, function() { 
        jQuery(this).fadeIn(200, function() { 
            jQuery('#waitingDiv').hide(); 
        }); 
    }); 
    }); 
} 
 
//JPlayer initiation code on first page load 
jQuery("#jquery_jplayer_1").jPlayer({ 
    ready: function () { 
        jQuery(this).jPlayer("setMedia", {mp3: '../'+path}); 
    }, 
    swfPath: "../swf", 
    supplied: "mp3", 
    wmode: "window" 
}); 

有什么建议吗?

谢谢 阿基莱什·阿加瓦尔

请您参考如下方法:

尝试将 JPlayer 启动代码移至 loadContent 函数上方