JavaScript插件在Safari中不工作

问题描述:

我在Wordpress中安装了一个插件。插件名称是很好的背景音乐。除了使用Safari之外,该插件可以在所有浏览器上工作:声音不播放,按钮暂停不起作用。JavaScript插件在Safari中不工作

的错误是:

类型错误未定义是不是一个函数
(评估_this.audio_player_element.pause()')

这个链接下载文件JS

https://www.wetransfer.com/downloads/c2169c2ad8096778decaed1df7304cd520160530203306/397086fa9a12eba87669072851c7e0da20160530203306/33f9d1

+0

'_this'定义在哪里? –

+0

开始代码javascript war_SoundyFrontEnd.prototype.initPPButton = function() { \t var _this = this;

+1

请修改您的问题以添加展开的代码段,而不是在评论中添加代码 –

1)因为有.attr(),我假设你使用jQuery 你可能会使用多个jquery脚本(彼此竞争)。

2)因为存在_这是你的范围,你实际上可能会调用超出范围的对象。 3)如果你使用的脚本不适用于Safari,那么这就是发生了什么。

if(_this.audio_player_element.paused) 
    { 
    //you will never reach this because audio_player_element is undefined which gives false due to your scope or being taken by another jquery $ script 
    } 
     else 
    { 
    //you will always end up here, and you are trying to pause() the undefined. 
    } 
+0

我有粘贴链接下载文件js。 –