-2

my javascript based redirect code works well on mozilla and chrome but in internet explorer it doesnt work. here code :

<option onclick="location.href='location'">GO</option>

EDIT : Error Detection: internet exploer doesn't support onclick event for option tag.

Solvation:

HTML:

<select onchange="redirecttooperator(this);">
<option value="location">GO 1</option>";
</select>

JS:

function redirecttooperator(select){
    var operator = select.options[select.selectedIndex].value;
        window.location.href = operator;
}
ngrashia
  • 9,869
  • 5
  • 43
  • 58
  • possible duplicate of [how to use onClick() or onSelect() on option tag in jsp page](http://stackoverflow.com/questions/3487263/how-to-use-onclick-or-onselect-on-option-tag-in-jsp-page) – Willem D'Haeseleer Aug 15 '14 at 10:12
  • who mark -1 point to my question. i have bad words for him. why -1 ? – TeknolojiGezgini Aug 15 '14 at 10:50
  • 3
    I did, Your questions is showing significant lack of research, that is why I down voted it. Please spare me from your bad words, the internet has enough already. – Willem D'Haeseleer Aug 15 '14 at 10:54
  • 2
    This also isn't your first question that gets down votes. You need to work more actively on improving your question quality and do basic research before you ask a question. – Willem D'Haeseleer Aug 15 '14 at 11:11

2 Answers2

0

HTML:

<select onchange="selectChanged();" id="select">
<option>GO</option>
</select>

JS:

function selectChanged() {
    var slct = document.getElementById("select");
    var slcted = slct.options[e.selectedIndex].value;
    if(slcted == "GO") {
        window.location.href = "location";
    }
}
chris97ong
  • 6,870
  • 7
  • 32
  • 52
-1

Use window.location instead of location.href

 window.location='http://google.com';
Boris
  • 360
  • 2
  • 12