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.

Dani AI

Generated

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:

  • Inspect the image link. If it already has target="_blank", make sure no JS also opens it.
  • In DevTools, look for multiple click listeners on the image and its ancestors (Event Listeners panel). If you see duplicates, you likely have init code running twice (e.g., after PJAX/infinite scroll).
  • Test with a clean profile or extensions disabled to rule out add-ons that re-open links.
  • If a fix was deployed but some users still see it, ask them to hard refresh, disable cache in DevTools, or clear site data for the domain to bust stale assets.

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.

Recommended Answers

All 4 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.