0

I have a combobox that calls a URL when the value is changed (the blue Specialty button on http://bobclass.com/). This works fine on desktop and Android but the event is ignored on iPad (regardless of Safari or Chrome). In the javascript I used:

$('#speciality').on('change', function(e) {
    var selected = this.options[this.selectedIndex].value;
    e.preventDefault();
    setTimeout(function () {
   // iOS 7 hack?
   top.location.href = selected;
}, 10);

The Timeout was suggested elsewhere on this forum but I still cannot get it to work. Anyone a clue or is this an iOS7 bug? Thanks!

  • You can try enabling remote debuging to find more detailed info about the error. Also this reference might be different under IOS. Have you tried it like this window.location = selected; – Jacob Dec 13 '13 at 13:49
  • Thanks for the suggestions Jacob. I tested and dug deeper and found the answer elsewhere on stackoverflow, see below. (the highest voted solution) - not sure what actually made the difference, probably the window.location you mentioned. – robbiego Dec 16 '13 at 13:00

1 Answers1

0

The answer was found here: Onchange open URL via select - jQuery. This is the code:

 <select id="dynamic_select">
        <option value="" selected>Pick a Website</option>
        <option value="http://www.google.com/">Google</option>
        <option value="http://www.youtube.com/">YouTube</option>
        <option value="http://www.stackoverflow.com/">Stack Overflow</option>
    </select>   
    <script>
        $(function(){
          // bind change event to select
          $('#dynamic_select').bind('change', function () {
              var url = $(this).val(); // get selected value
              if (url) { // require a URL
                  window.location = url; // redirect
              }
              return false;
          });
        });
    </script>
Community
  • 1
  • 1