简体   繁体   中英

Href vs select box

I use my web space in a non-Professional way though I own a web page with some links and use Javascript to automatically load the url.

http://samuel.dumont.pagesperso-orange.fr/

I wanted JS to open in _self or _blank .
It's ok with regular href links for both target even with the "block popup" feature of the browser but on select box (with onChange event) _blank is only granted with this feature off. Does href encode url differently from a select box value ?
Is there a wizard tips to locally overcome this feature ?

Fixed your function, tested on my localhost, link opens in new tab.

<a href="Javascript:GoTowww('http://goggle.com/')">Google</a>


function GoTowww(url) {     
  window.open(url,'_blank');
} 

I find a solution for your checkboxes

Here's a Fiddle

<select onchange="window.open(this.options[this.selectedIndex].value,'_blank')">
  <option value="">Choose</option>
  <option value="http://www.yahoo.com/">Yahoo</option>
  <option value="http://www.google.com/">Google</option>
  <option value="http://www.stackoverflow.com/">Stackoverflow</option>
</select>

more resource Here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM