0

Tested in Chrome 20, FF 13, IE 9, Safari 5.1.7.

Can anyone tell me why the following code works in Chrome, Firefox and IE, but not in Safari?

<select id="mySelectBox" onChange="window.open(options[selectedIndex].value);">
<option value="" selected="selected" >Choose a search engine.</option>
<option value="http://www.google.com" >Google</option>
<option value="http://www.bing.com" >Bing</option>
<option value="http://www.yahoo.com" >Yahoo</option>
</select>

My feeling is that Safari is doing the right thing. I shouldn't be able to reference the options property and selectedIndex property without using the this keyword or the more verbose document.getElementById('mySelectBox').

What's going on?

Thanks!

JulianJohannesen
  • 346
  • 3
  • 11

1 Answers1

1

If you have Safari's "Block Pop-up Windows" setting checked that will stop this from working.

j08691
  • 204,283
  • 31
  • 260
  • 272
  • This is also blocked in Chrome now as well. http://stackoverflow.com/questions/30466129/window-open-blocked-by-chrome-with-change-event – Ryan Kara Mar 02 '16 at 15:42