Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
Open to new window or tab on click

I am trying to make different countries in this map (http://jsfiddle.net/hansenmc/EnqP3/) open to a new tab or window. I am able to open in the same window without an issue using this code.

     onRegionClick: function (element, code, region) {
        
        
        if(code == 'il'){
window.open("www.mywebsite.com", "_blank");
}

When I use this code it opens in the same window and a new window simultaneously.

    onRegionClick: function (element, code, region) {
        
        
        if(code == 'us'){
window.open = "www.mywebsite.com, _blank";
}

Any help getting different countries to open into their own window would be greatly appreciated. I have tried solutions from other threads but none seem to work in this scenario.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You could use the Event object .preventDefault() method on windown.open().

about 4 years ago · Juan Pablo Isaza Report

0

window.open is a function, so it should be called instead of assigned to.

Instead of:

window.open = "www.mywebsite.com, _blank";

It should be:

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

Also, if you want the function open the URL correctly, it should include the http(s):// prefix, otherwise it will open a relative path from the current windows location in some browsers.

The full code in your case would be:

onRegionClick: function (element, code, region) {
    if(code == 'us'){
        window.open("www.mywebsite.com", "_blank");
    }
}

Shorter version:

onRegionClick(element, code, region) => {
    if(code == 'us')
        window.open("www.mywebsite.com", "_blank");
}

For a dynamic URL, something like the following would work:

onRegionClick(element, code, region) => {
    if(code == 'us')
        window.open(`www.mywebsite.com/${code}`, "_blank");
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!