加载Soundcloud嵌入式播放器OnClick在FireFox中不工作
Load Soundcloud embedded player OnClick not working in FireFox
网站:https://www.buybeatsfast.com/beats/
点击"播放节拍"图像应该加载该曲目的Soundcloud播放器并自动播放。这在Chrome中有效,但在Firefox中它只会带你进入Soundcloud曲目的页面。我在Windows XP和Windows 8上测试了这个,但它在Firefox中根本不起作用,控制台上也没有错误,所以我不知道问题是什么,我不是这个代码的作者,实际上我在这里找到了它。
这是html:
<div class="tempsc"><a href="https://soundcloud.com/rockitpro/imstillherehook" class="scload"><span class="playbeat"><span class="icon-play-sign playbeaticon"></span> Play Beat</span></a></div>
这是js:
/*SOUNDCLOUD CLICK TO PLAY*/
var formatPlayer = '&iframe=true';
formatPlayer += '&color=3498DB';
formatPlayer += '&buying=false';
formatPlayer += '&download=false';
formatPlayer += '&show_playcount=false';
formatPlayer += '&show_reposts=false';
formatPlayer += '&show_user=false';
formatPlayer += '&show_comments=false';
formatPlayer += '&liking=false';
formatPlayer += '&hide_related=true';
formatPlayer += '&sharing=false';
formatPlayer += '&maxheight=125';
formatPlayer += '&auto_play=true'; // Play once user clicks link!
formatPlayer += '&show_artwork=true';
//LOAD IFRAME ON CLICK
$('.scload').click(function(){
event.preventDefault();
var $link = $(this);
var getJSONstring = 'https://soundcloud.com/oembed?format=js&url=' + $link.attr('href') + formatPlayer;
//Replace contents
$.getJSON(getJSONstring + '&callback=?', function(response) {
var widget = response.html;
var src = $(widget).attr('src');
widget = $(widget).attr('src', src.replace('?visual=true', '?visual=false')); // Update iFrame src
$link.replaceWith(widget); }); });
已修复。忘记将event
传递到click
函数中。这现在在Firefox中有效。
/*SOUNDCLOUD CLICK TO PLAY*/
var formatPlayer = '&iframe=true';
formatPlayer += '&color=3498DB';
formatPlayer += '&buying=false';
formatPlayer += '&download=false';
formatPlayer += '&show_playcount=false';
formatPlayer += '&show_reposts=false';
formatPlayer += '&show_user=false';
formatPlayer += '&show_comments=false';
formatPlayer += '&liking=false';
formatPlayer += '&hide_related=true';
formatPlayer += '&sharing=false';
formatPlayer += '&maxheight=125';
formatPlayer += '&auto_play=true'; // Play once user clicks link!
formatPlayer += '&show_artwork=true';
//LOAD IFRAME ON CLICK
$('.scload').click(function (e) {
e.preventDefault();
var $link = $(this);
var getJSONstring = 'https://soundcloud.com/oembed?format=js&url=' + $link.attr('href') + formatPlayer;
//Replace contents
$.getJSON(getJSONstring + '&callback=?', function(response) {
var widget = response.html;
var src = $(widget).attr('src');
widget = $(widget).attr('src', src.replace('?visual=true', '?visual=false')); // Update iFrame src
$link.replaceWith(widget); }); });
相关文章:
- 为什么这在IE中的工作方式与在Firefox中不同
- JS可以在Chrome中工作,但不能在Firefox中工作
- Facebook登录按钮没有'不能在Firefox上工作
- JS在firefox中无法正常工作
- firefox插件:退出不工作的应用程序观察器
- :focus:一起活跃,不在firefox上工作
- 加载Soundcloud嵌入式播放器OnClick在FireFox中不工作
- javascript()onclick隐藏元素-dos'我不在firefox工作
- 异步加载的SVG过滤器feColorMatrix在Chrome中工作,而不是在Safari或Firefox中
- Iframe加载调整大小在Chrome中工作,但不能在IE或Firefox中工作
- 按钮处于活动状态,焦点无法在Mac FireFox上工作
- HTML5 Canvas undo是'在IE或Firefox中无法正常工作
- 形式方法”;POST”;不在firefox工作
- Jquery倒计时显示NaN在Safari,在Chrome / Firefox工作良好
- IE 11似乎降低了.options的限制[]- firefox工作正常- IE <11工作正常
- javascript显示选项卡获胜'我不在firefox工作
- 登录功能没有'我不在firefox工作,但在chrome、IE、safari和opera上工作
- 尝试在html5中访问网络摄像头:Firefox工作,Chrome和Opera don't
- 在d3js布局中使用XML作为数据源;我不在firefox工作
- jquery切换不工作在chrome,但在IE和firefox工作