I have a web application running in one or more browser tabs/windows. I also have a SharedWorker, which is connected to every single one tab/window and is also communicating with some server over websocket. To this point everything works as expected and without any problems.
There, I also have a single popup window (opened automatically or with user interaction, it doesn't matter) with some SIP/WebRTC plugin. After it's opened, I can communicate with it over the same SharedWorker as everything else and that's OK.
SharedWorker also keeps (or, at least, is trying) information about every connected tab/window - based on connect event in worker and beforeUnload in every other tab/window. Not the best solution, but only one I found working.
Everything runs on the same domain, in the same location.
Now, I can't find any solution to:
get the popup window handle from other tab/window than its opener, nor it's not possible to transfer handle to SharedWorker
react to close of popup window every time, cause in some point that window worker port gets lost
focus popup window from every other tab/window, cause there's no handle to it
Related
I am developing my web app in React on Chrome.
I have tried...
To get a reference of the Window object of one tab from the other tab,
but I can do this only if I use window.open() witch opens a new tab and I need to get a reference to an existing tab.
Also changing window.name and then window.open('', 'windowName') didn't help.
Maybe there is a way to get the Window reference of an existing tab without opening a new one?
To open a UDP socket but I failed to (I think it is not possible on Chrome).
To open a TCP socket, but it requires a TCP server witch as far as I read, chrome client can't open one.
Local storage is shareable only between tabs from same origin (or aren't they?).
I'm using a web framework where everything gets passed through a websocket. New / updated DOM elements are shipped over to the browser, events get shipped back to the server. Works great. Except when the websocket gets closed.
This happens...
when using desktop/mobile Safari's browser navigation buttons are used to leave & come back to the page
on mobile Safari after a timeout when switching to a different app, tab or screen locking
when the WiFi goes down etc.
After that the user simply sees a normal looking page, but everything is obviously dead as no more updates happen and no more events get relayed to the server. I'd like to simply refresh the page in that case. Either everything goes back to normal or the user sees a connection error in case of no network etc.
I tried poking around in the framework's code, adding "window.location.reload(true);" to the "onclose" handler for the websocket kinda does the trick. My state is 100% on the server, so reloading the page will just fix things.
Assuming I can't modify / fix the web framework I'm using, and it doesn't have any onConnectionLost client-side event, what's my best option to detect this scenario and reload the page? Are there any events like 'onPageDisplayedButNotProperlyReloaded', 'onPageVisibleButHasBecomeStaleInTheMeantime', 'onWebSocketsClosed' for me to use? Can I just open some dummy websocket and reload the page when it gets closed or something? Any other good way to detect this?
Thanks!
I'm having an issue where closing my Chrome App too quickly after completing a stage corrupts the save data. This is because it's in the middle of saving some data.
Is there any way to keep the Chrome App open for a few seconds after the user presses close or alt+f4? Or another solution that maybe has a popup telling the user that the app is saving and will close automatically?
You can use the chrome.runtime.onSuspend.addListener( function ) method to specify some code to run when the user quits the app. As stated in the chrome documentation, any code running or triggered in the background/event page will keep the program alive for a short time to allow these processes to end. Remember to register this event listener method in your background/event page before the user has a chance to quit.
Additional information here:
https://developer.chrome.com/extensions/runtime#event-onSuspend
I have one web application. When client enters the address and after successfully logging in. He gets the home page with some data over the page. Now when any third party tool or from run command if i give the same url on which the client is with changed parameter values, i want the same browser window to be refreshed with updated/changed values without opening the new browser window.
Whats happening now is that when i'm triggering the url from different source, its opening in new browser window. Plz help me out with few suggestions.
Ars.
The best solution would be for the web application to poll the server and refresh itself when there is an update.
Your command line tool can then contact the server and update the parameters directly, and the application in the user's browser will pick up those changes automatically.
Attaching to a running Internet Explorer instance is also possible, for example see this article: http://www.codeproject.com/Articles/9683/Automating-Internet-Explorer, or the Selenium project at http://seleniumhq.org/. But you're almost certainly going to make it easier for yourself by changing your application to refresh automatically.
I am working on a multiplayer chess game as a Facebook app.
If one player leaves the game by closing the browser the other player should get a notification. So if one player closes the Browser, a unlink function should be called to unlink the player. This works fine with onunload outside Facebook.
The problem is, that the Facebook apps are loaded in iframes and the onunload event doesn't work there.
So I need a way to call a function inside an iframe when a user is closing the browser.
This is probably not the answer you are looking for but "logging off" on unload will never work reliably. For an extreme example, consider the case where the browser crashes or is killed via the Windows task manager. So you better implement an additional mechanism to detect whether a user left. Typically this is done by sending a request to the server periodically. If this request isn't received for a significant time (meaning something that cannot be caused by a slow connection or other hiccups) you unlink the user.
That said, I tested Firefox 4 and MSIE 8 and both correctly fire unload event on the frame if the tab or the browser is closed. Chrome 12 doesn't do that, that's probably the browser you have been testing with. I consider it a Chrome bug.