It makes use of the fact that a duplicated tab has no name. The code below forces a signon page to appear in the duplicated tab if they duplicate a signed on session. The issue was that the browser duplicate tab facility messed up the enforcement. ![]() The signon uses localStorage flags to enforce this requirement and uses the window.name to know which user owns the tab. My application required that a user can only sign on once so I can use the localStorage to reliably cache records. ![]() $('#myStateInput').val('') // Blank the state out. $(window).on('beforeunload', function() // Back or Forward buttons This works because onbeforeunload gets only called when the user clicks "Back" or "Forward" but not when duplicating a tab. To do this we can blank out the state in onbeforeunload. ![]() Thats great and all, but you only want to detect when you "Duplicate tab". $('#myStateInput').val('already loaded') // Set stateĪlert("Loaded with state. If ($('#myStateInput').val() = '') // Load with no state. The "Duplicate tab" action works almost exactly like when reloading a page after the user has clicked "Back" then "Forward", so you are basically implementing a version of this question: function onLoad() ![]() Just to clarify: The goal is to is to detect (and close) a tab that has been opened via Chrome's "Duplicate" right-click menu option.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |