Prototype Event.observe(window, 'change', function() - Not working in IE Browser
Prototype, Event.observer 'window' 'change' is not working in IE browser /its working fine in Mozilla,chrome browser. Can you any one give the solution for this? Code:
<script type="text/javascript">
Event.observe(window, 'change', function() {
alert("Loaded!");
var opt0=document.getElementsByTagName("option")[0];
var opt1=document.getElementsByTagName("option")[1];
var opt2=document.getElementsByTagName("option")[2];
var opt3=document.getElementsByTagName("option")[3];
var opt4=document.getElementsByTagName("option"开发者_开发技巧)[4];
if(opt0.selected==true || opt4.selected==true) {
document.getElementById("chgButton").style.marginLeft="0em";
}
if(opt1.selected==true) {
document.getElementById("chgButton").style.marginLeft="4em";
}
if(opt2.selected==true) {
document.getElementById("chgButton").style.marginLeft="8em";
}
if(opt3.selected==true) {
document.getElementById("chgButton").style.marginLeft="12em";
}
// some more code down here, but even without it it doesn't work!
});
</script>
<div>
<div style="float:left;">
<select>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<div style="float:right;">
<input type="button" value="submit" id="chgButton"/>
</div>
</div>
</div>
Thanks in advance ps
What do you expect to happen? If you're trying to use event bubbling then you might have better luck with document
or document.body
or something much more specific like the form element that contains those inputs.
精彩评论