简体   繁体   中英

How Do I know my site is not running on another tab in a same browser?

How Do I know my site is not running on another tab in a same browser? Any function or script exist which is give me how many tab has running my site in a same browser?

  1. Page loads
    • Store a value in a cookie
  2. Page unloads
    • Remove cookie

If at step 1. the cookie already exists then do what you need to do ;)

Very basic and naive solution!

I think there is a way to do cross tab communication, but I can't remember what it's called... or maybe i'm dreaming.

Edit: The localStorage change event might also be of help

You could check is a session variable is set? this should pick up in the same browser different tab

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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