Aniket
Aniket

Reputation: 2214

Opening new link in new tab

Hi I am working on j2ee web application. But I am facing one problem when I am trying to open clicked new link in new tab. As if it is opening new tab but it is appending url link over my web application root context path.

My web page where I am clicking.

enter image description here

And the error page shown below,

enter image description here

As you can see I am able to open new tab but problem is it link is appended with root path shown by yellow color.

I tried this by this code,

window.open("www.yahoo.com", "_blank");

also tried using,

<a href="www.yahoo.com" target="_blank">Click Me</a>

Upvotes: 1

Views: 1483

Answers (3)

Karthik Surianarayanan
Karthik Surianarayanan

Reputation: 626

target="_blank"

This is the code to say the link should be opened in a blank page.

Upvotes: 0

Gabriele Petrioli
Gabriele Petrioli

Reputation: 195952

if you do not specify a protocol then it is assumed to be a local address (local to your website)

So use http:// at the start..

Upvotes: 2

Alessandro Minoccheri
Alessandro Minoccheri

Reputation: 35963

if you don't specify http:// the standard is to take the path of your site in this case localhost:8080..
try this:

<a href="http://www.yahoo.com" target="_blank">Click Me</a>

or this:

window.open("http://www.yahoo.com", "_blank");

Upvotes: 4

Related Questions