In a simplistic way, any “A” (anchor) element can have a target=”_blank” or target=”someName” attribute, which by default will open a new tab or window for the next page. If something goes through the page and manipulates each A which has a target attribute, and forces it to have the value “_top” instead, your desired behavior will at least come close. However, there are some pages which split up the main page into multiple frames, each with a target. An example would be a manual with links to chapters or topics on the (usually left) side of the page, and when the topic is clicked, it changes the contents of another frame.

And then….then there are the poor, misguided Web designers who want to press their wrists into the sides of your head right in front of your ears in order to steer your head towards what they want you to look at, hold your arm at the wrist of whichever side you usually use for your mouse, trackpad, or trackball, and press your fingers ONLY on the main (by default, left) “mouse” button. First, for the parts of the page you’re supposed to manipulate, they don’t use standard Web page elements, they use their own DIVs, SPANs, and styling to make these page elements LOOK like their browser built-in counterparts, and attach event handlers to these elements to handle clicks, keypresses, etc. in their own custom way (sometimes in the mistaken idea of increasing security. Ever use a page, usually of a financial institution, where it doesn’t let you type Ctrl-V in order to paste a dollar amount which for example you may have copied from a previously downloaded bill PDF? Yep, that’s JavaScript/ECMAScript.). There is extremely little you can do unless you have ECMAScript skills, use something like Tampermonkey, and you need to handle each such page on a case-by-case basis. And there’s no guarantee Tampermonkey or its ilk are capable of doing ANY page manipulations, because the page may have been served with a security directive which may cause your browser not to execute any scripts other than the page intends (Content Security Policy headers).

What would be necessary is some sort of analyzer code, perhaps an AI, which could determine what these pages were trying to do and act accordingly to keep it all in a single window or tab. You just never know what might happen if for example an extension intercepted all calls to window.open() and attempts to use targets other than _top.

Can you tell I’m annoyed by these practices, and attempted to program some countermeasures? 🙂

This reply was modified 3 weeks, 6 days ago by RChandra. Reason: final comment about how I tried tackling the problem