I am trying to figure out how to detect tab that is created straight by duplicating existing tab ( not by adding new tab and using the same URL) Duplicate tab seems sharing viewstate with the tab it was duplicated from and page created without being rendered from the server. The simple approach by creating hidden input initializing it into empty string and assigning value on the first time page load is not working as on duplication the hidden input intermittently empty again... Any approach how specifically detect that page is result of the duplicate action on the browser in the page 'load' event added to the event listener.. Thanks
Asked
Active
Viewed 71 times
1
-
I never use duplicate tab, but it does indeed copy viewstate, and I was not aware that it does. As a result, I don't think can you detect when this occurs. You as a general rule can't see or touch other tabs, since that other tab might be doing your banking, and I can't thus get to mess and see that fact from my site. However, this most certainly does present a problem and challenge, since no events are triggered when you duplicate browser tabs. – Albert D. Kallal May 24 '23 at 15:02
2 Answers
0
ok, so no one is biting here.
It turns out you CAN detect if the page in question was navigated to by back button, forward button, or in this case duplicate.
How to do this is outlined in this post:

Albert D. Kallal
- 42,205
- 3
- 34
- 51
0
I tried the method listed, I might did something wrong, but I created hidden var, but somehow on duplicate page it was still get initialize into empty so it did not work... eventually the following approach produced desirable result...
window.addEventListener('load', function () {
var loadItem = document.baseURI + "~~" + $("input[id$=hdnMasterPageIndx]").val()
if (localStorage.getItem(loadItem) === null ) {
localStorage.setItem(loadItem, 'DoNotDuplicate');
window.addEventListener('unload', function () {
localStorage.removeItem(loadItem);
})
} else {
DuplicatePageNotice()
}
hdnMasterPageIndx this is server side hidden input.. value get stored in the session and increased every time page get rendered from the server... so on tab duplication it still in the local storage. It works on postbacks as the value got removed before come back. DuplicatePageNotice is jQuery pop up that after user get notified sends to the app's home page.

abx222
- 11
- 3