What are you trying to accomplish.
Clicking on an A element moves the window to the A elements referenced location and by default it refreshes the page.
Opening a link takes you to that link.
I want to open all the links in the selected element â each link in a new tab.
Hence, if the element contains 10 a elements â 10 new tabs would be created.
The links donât have a target attribute.
The links are created by a CMS so I generally donât control their attributes (besides the href ).
To open in a new tab or new window you need target="_blank" attributes otherwise they will open in the same tab in quick succession. Even then you cannot control whether a browser will open in a new tab or in a new window. Anyway my Firefox, Chrome and Edge block all such popups from opening.
You could have the links open in iframes on the same web page.
Is that href attribute correct? Is index.php a file within a folder named âENCODINGâ? So should it not be href="/ENCODING/index.php" ?
I have uploaded a demonstration of the JavaScript working here: http://flexi.epizy.com/links1.html
Thatâs on free webspace so you may get a security warning.
Is the fullest link pattern I get from the MediaWiki content management system.
I donât know why the MediaWiki community chose to format links with /index.php/.
I wonder if you are seeing your web page refreshed, not the web page you want, because the relative URLs are incorrect.
I believe that I was wrong to use the term ârefreshedâ, nothing is really refreshed:
I just get a new tab with the same URL as of the previous tab (i.e. the one I ran the code at).
Anyway, I wonder whether itâs worth continuing with this approach because of the impact of browser popup blockers.
I too think that this strange behavior comes from popup blocker, because:
If I configure the popup blocker to not block popups for the respective domain, than the new tab with the same URL as of the previous one problem no longer happens but if I flush all browser cache (pop up blocking comes back), than this problem comes back as well
Why would a unconfigured pop up blocker cause a new tab with the same webpage of the previous one to be created this way?
I donât have a clue.
Itâs even stranger that this problem happened both in Chrome and Edge browsers.
If you open one of those linked pages directly using your browser without using the JavaScript code, what URL do you see in your browserâs address bar? Surely that is more than just: /index.php/ENCODING.
@Archibald I have deleted the post above yours.
I am sorry for the mistake in saying that I read full links in the DOM, I didnât.
I only read these in the link preview in the bottom-left part of the window and as the URL in web pages accessible from these links.
I donât know why MediaWiki doesnât have full links in the href.