触发音频停在iframe中,当父窗口导航离开(hashbang)停在、音频、窗口、iframe

2023-09-10 14:38:48 作者:如今的你还在拼命爱吗

我有一个网页(脸谱)上的iframe(Facebook的标签应用程序)的Web应用程序。

I have a web app in an iframe (Facebook Tab App) on a web page (Facebook).

Web应用程序播放音频,而当用户离开,通常是通过点击另一个Facebook的链接时,页面加载另一个Facebook页面和音频停止。

The web app plays audio and when the user navigates away, usually by clicking on another Facebook link, the page loads another Facebook page and the audio stops.

这适用于除的Internet Explorer(IE9)所有的浏览器。音频继续当我浏览到另一个Facebook页面播放。

Facebook的似乎用不标准的刷新页面,许多自己的网页中显示的方式(使用hashbang#!方法)。对我来说:这意味着Web应用程序的音频继续播放(iframe的是某种孤立的?)。

Facebook seems to use the approach where many of their pages are displayed (using hashbang #! approach) without standard page reloading. For me: this means the web app's audio continues to play (the iframe is somehow orphaned?).

音频停止,当您导航到不使用#另一个网站玩! URL语法和浏览器通过重新加载这些页面。

The audio stops playing when you navigate to another site that doesn't use the #! URL syntax and the browser properly reloads those pages.

我能做些什么,以确保我的Web应用程序(Facebook的标签应用程序)的声音停止,当我浏览到另一个Facebook页面我在看如何?

在父检测触发相应事件 在明确关闭的声音在我的web应用程序

推荐答案

我设法通过窗口钩到卸载事件,如

I managed to resolve this by hooking onto the unload event on the window, like

$(window).unload(function() {
  var a = $("#audio");
    a.get(0).pause();
});
 
精彩推荐
图片推荐