简体   繁体   English

重新加载后与弹出窗口重新连接

[英]Reconnect with popup window after reload

I have music player, that consists of two parts. 我有音乐播放器,它由两部分组成。 First, the main page is page, where you can pick songs from database, add them to playlist,... The other window is player itself (displays sound controls, current playlist, album cover,...). 首先,主页是页面,您可以在其中从数据库中选择歌曲,将它们添加到播放列表中,...另一个窗口是播放器本身(显示声音控件,当前播放列表,专辑封面等)。 Player window is opened using window.open in main window. 使用主窗口中的window.open打开播放器窗口。

I want to leave player window open, even when you close the main window, so you can do other things and have the music still playing and controllable. 我想让播放器窗口保持打开状态,即使关闭主窗口也是如此,这样您就可以做其他事情并使音乐仍在播放且可控制。

My problem is, after reopening the main page, is there a way to connect to player window again? 我的问题是,重新打开主页后,是否可以再次连接到播放器窗口? Or at least, close it and reopen it? 或者至少关闭它并重新打开它?

I couldn't find any way to do this. 我找不到任何方法可以做到这一点。 If it isn't possible, I had and idea, that main page could communicate with player through LocalStorage (both sides would be periodically checking if there is anything new). 我有一个主意,如果不可能,那么该主页可以通过LocalStorage与播放器进行通信(双方将定期检查是否有任何新变化)。 Is there any better method? 有没有更好的方法?

Intercom is a library that uses local storage to implement broadcast messaging between windows. 对讲机是使用本地存储在Windows之间实现广播消息传递的库。

Local storage fires an event ( onstorage ) when data changes, so no polling is necessary. 本地存储在数据更改时触发一个事件( onstorage ),因此不需要轮询。 Intercom allows all pages on a domain to communicate, regardless of how they were opened. 对讲机允许域中的所有页面进行通信,而不管它们如何打开。

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

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