Over a million developers have joined DZone.

Javascript Tweak To Open URL Either In A New Window Or New Tab Based On User's Choice

I am facing an issue where a link on my website opens in a new window if you simply click on it. However, if you right click and say open in new window or new tab, it opens the same window (URL) again from where the link is clicked.

Self Service Option is a link and the JSP calls a function getSelfServSite() when the link is clicked. This is how the code flows in my case

function getSelfServSite()
   // this is because the URL is configurable

function getToTheLink(url) 
   window.open (url, "currentWindow", "");
What am I doing wrong. I want it to go to the right link no matter how the user click it.

Please advise. Thanks

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}