Is it possible to detect if a user has opened a link in a new tab?

You can sort of do it like this:

if (history.length == 1) {  // Um, needs to be 0 for IE, 1 for Firefox
    // This is a new window or a new tab.
}

There may be other ways for history.length to be 1, but I don’t know what they might be.

Leave a Comment