Skip to content Skip to sidebar Skip to footer

Get Opened Pages/tabs With Mootools

I have a site that need to know if the user have other pages/tabs opened just to make actions in them (like closing them, redirect etc..). I'm not talking about popups, I'm talking

Solution 1:

I think it might be possible, since you say it's all on the same domain.

When a page/tab gets loaded, you want to assign it an unique id and send it to the server. When it gets closed you will need to tell the server about it as well, so the server knows what tabs are still open. In each open tab you can then regularly query the server for any actions that you want to happen in this tab, like redirecting or closing it.

Solution 2:

Not possible with javascript, and with good reason.

Do you really want websites to start redirecting your other tabs?

Solution 3:

Actually, this IS possible, and you don't need to go through constant server requests. Use localStorage, and bind to the storage event. The implementation is actually really simple. The only serious gotcha is that not all browsers follow the specification for whether the storage event is fired on the origin window, but with a few lines of code you can normalize the behavior.

Post a Comment for "Get Opened Pages/tabs With Mootools"