0

I'm trying to add a simple link to a help site to a navigation pane. Since the help site is external to the rest of the web application, I'd like to open the page in a new browser tab/window. Just add target="_blank" as an attribute to the HTML <a> tag, right?

The trouble is, only relative links get opened in the new window/tab for reasons that I cannot fathom. So, <a href="helpsite.com/helpPage" target="_blank">Help</a> opens the (broken) link in a new window. But if I try to use the absolute URL <a href="http://helpsite.com/helpPage" target="_blank">Help</a>, the page will open in the same window.

This problem manifests across all web browsers (Mozilla Firefox, Google Chrome, and IE 9 tried). In IE, I notice that it looks like I'm temporarily on a blank page, then redirected to the help site. So, it's as though the browser is going through the normal procedure, but all in the same tab.

The problem also occurs when I click on the link with the middle mouse button, but not if I right-click and choose "Open link in new tab."

The page in question is part of a Grails application, built on Grails 2.0.1, but the code for the link in the gsp is plain ol' HTML. It happens no matter where I put the link--in my navigation template or in the middle of a basic GSP.

I've tried copy-and-pasting the link HTML into a plain text HTML file, and it works just fine. I'm not including any javascript I wrote, though our common site template that we use does include a common Javascript file used by almost all of our web apps and pages.

I am at my wits' end. Any thoughts?

jonnybot
  • 2,435
  • 1
  • 32
  • 56
  • What about a javascript `window.open(url)` ? – Benjamin Gruenbaum Feb 06 '13 at 22:35
  • Have you checked that the tag actually ends up as you think? Changing the `href` should not change the behaviour of the `target` attribute, but an error in the markup might make the browser ignore the `target` attribute. No missing quotation marks, or something like that? – Guffa Feb 06 '13 at 22:39
  • That's odd: http://fiddle.jshell.net/7Ya7W/3/show/ – Blender Feb 06 '13 at 22:40
  • Something must be wrong with the rendered HTML. – Pete Feb 06 '13 at 22:40
  • I've narrowed it down to a common javascript file included in our site template. If I remove that script, the link works normally. If not, it doesn't. The JS file is huge, though. Working on getting a version with whitespace. – jonnybot Feb 06 '13 at 22:45
  • So it is a JavaScript issue, even though the question says “has no Javascript”. – Jukka K. Korpela Feb 07 '13 at 05:21
  • Fair point, Jukka. Updated question accordingly. – jonnybot Feb 25 '13 at 14:22

1 Answers1

0

So, the problem turned out to be the common javascript file used on our site, which uses regex to parse links for Google Analytics purposes.

I know. I know. This probably should not happen. RegEx match open tags except XHTML self-contained tags

That decision is out of my hands, though. Thankfully, those who do hold that decision were able to quickly update the common javascript file so that it didn't cause this particular problem.

Community
  • 1
  • 1
jonnybot
  • 2,435
  • 1
  • 32
  • 56