简体   繁体   中英

select onchange not working in ipad safari

I have a jumpbox which should work onchange to the second select box. This works everywhere EXCEPT on iPad Safari. Can anyone help me to figure out what do I need to do to get it to work?

I've set up a jsfiddle: http://jsfiddle.net/lbriquet/5m7U3/1/

Standalone example: http://fiddle.jshell.net/lbriquet/5m7U3/1/show/

The select box onchange uses:

<select name="jumpMenu" size="12" id="jumpMenu" onChange="MM_jumpMenu('window',this,document.getElementById('ORGID'),0)">

The function it calls is:

function MM_jumpMenu(targ, selObj, selObj2, restore) { //v3.0   

var url = '';
var tmp = selObj.options[selObj.selectedIndex].text;

switch (tmp) {
    case 'Membership':
        url = targ + ".open('" + selObj.options[selObj.selectedIndex].value + selObj2.options[selObj2.selectedIndex].value + '#2' + "')";
        break;
    case 'Officers':
        url = targ + ".open('" + selObj.options[selObj.selectedIndex].value + selObj2.options[selObj2.selectedIndex].value + '#3' + "')";
        break;
    case 'Liaisons':
        url = targ + ".open('" + selObj.options[selObj.selectedIndex].value + selObj2.options[selObj2.selectedIndex].value + '#4' + "')";
        break;
    case 'Subcommittees and WG':
        url = targ + ".open('" + selObj.options[selObj.selectedIndex].value + selObj2.options[selObj2.selectedIndex].value + '#1' + "')";
        break;
    default:
        url = targ + ".open('" + selObj.options[selObj.selectedIndex].value + selObj2.options[selObj2.selectedIndex].value + "')";
        break;
};

eval(url);
if (restore) selObj.selectedIndex = 0;

}

I found a solution. iOS7 safari was indeed blocking the select box from opening a new window, considering it a popup window. I added target "_self" at the end of the js building the url and it works now.

url = targ+".open('"+selObj.options[selObj.selectedIndex].value + selObj2.options[selObj2.selectedIndex].value + "','_self')";

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