Example: https://www.daniweb.com/programming/web-development/threads/518292/problem-in-php-showing-undefined-index-and-not-inserted-in-my-datasbase
Click on one image and I get two tabs with the same image on both tabs.
That's odd.
Example: https://www.daniweb.com/programming/web-development/threads/518292/problem-in-php-showing-undefined-index-and-not-inserted-in-my-datasbase
Click on one image and I get two tabs with the same image on both tabs.
That's odd.
Seeing two tabs open from a single image click usually means both the browser’s default link action and a script-driven open are firing. In practice, that happens when an <a> has target="_blank" and a click handler also calls window.open(...), or when two delegated click handlers run due to bubbling. A popup-block notice is a common clue that a second, scripted open was attempted. Nice catch by (and +1 to @alandavies for the hint that led there).
Quick checks if this ever resurfaces:
target="_blank", make sure no JS also opens it.Two safe patterns that avoid double-opens:
Let the browser handle it and remove JS opens:
<a class="attachment" href="image.jpg" target="_blank" rel="noopener">...</a> Or handle it in JS only (no target="_blank"), and prevent default exactly once:
const onClick = (e) => {
if (e.button !== 0 || e.metaKey || e.ctrlKey) return; // respect middle/cmd-click
e.preventDefault();
e.stopImmediatePropagation();
window.open(e.currentTarget.href, '_blank', 'noopener');
};
document.querySelectorAll('a.attachment').forEach(a => {
a.addEventListener('click', onClick, { once: true, capture: true });
}); Either approach ensures one click leads to one tab, consistently across browsers.
Jump to Post— alan.davies 185My android shows one new tab but states a pop-up window is blocked.
My android shows one new tab but states a pop-up window is blocked.
Yes I forgot to note host details. Windows 10, Firefox shows this behavior. Opera and Chrome just fine with a single image in a tab.
Thanks alan. I know details like this matters.
This is fixed, but it might take 24 hours for browser caches to clear before it goes itno effect. Or, you can clear your browser cache to force the update.
Thanks. Marking as solved.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.