简体   繁体   English

从backround页面chrome扩展名弹出窗口获取iframe

[英]get iframe from backround page chrome extension popup

I am making an extension that when you click on the icon, a popup comes up that displays http://html5.grooveshark.com/ and plays music. 我正在做一个扩展,当您单击该图标时,将弹出一个显示http://html5.grooveshark.com/并播放音乐的弹出窗口。 I want to be able to have it run in the background so the music will play, even after the person clicks away from the popup. 我希望能够在后台运行它,以便即使在该人单击弹出窗口之后也可以播放音乐。 If I set my "default_popup" to an HTML file with the code below, it shows Grooveshark, and plays music, but stops playing music after the popup is closed. 如果我将“ default_popup”设置为带有以下代码的HTML文件,它将显示Grooveshark,并播放音乐,但在关闭弹出窗口后停止播放音乐。 How do I get it to keep playing music in the background? 我如何才能在后台继续播放音乐?

Code (Displays Grooveshark.com) 代码(显示Grooveshark.com)

<!DOCTYPE html>
<html>

<style type="text/css">
        body {
             width: 500px;
             height: 300px;
             }
</style>

<body>


<iframe src="http://html5.grooveshark.com/" width="100%" height="500" frameborder="0"     scrolling="yes"></iframe>

</body>

</html>

您可以从始终运行的后台页面播放它,也可以打开一个包含iframe的无边界小窗口。

Just create a background.html and place your code in there. 只需创建一个background.html并将代码放在其中即可。 You can check that it is playing by setting an autoplay on your source. 您可以通过在源上设置自动播放来检查它是否正在播放。

Then, you just have to embed your background.html in your popup.html! 然后,您只需要将background.html嵌入到popup.html中即可!

So, your call in the popup would basically be: 因此,您在弹出窗口中的调用基本上是:

<iframe src="path/to/background.html"></iframe>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM