Is it by design that the Opera browser does not allow a <label> to fire the onclick event for its target element, or am I missing something here?
Here's an example w/ a workaround (maybe unnecessary?):
<html><head>
<style>
body{background:#fff;color:#000;text-align:center}
.inp{border:1px solid #fff;color:#000}
.dsc{color:#444;font-size:smaller;margin-bottom:10px}
.box1{border:3px double green;padding:6px}
.box2{border:3px double blue;padding:6px}
em{color:red}
</style>
</head><body>
- Opera browser -
<form>
<p>
<div class="dsc">must click checkbox for event</div>
<span class="box1">
<label for="cb1">
<em>label</em>&larr;</label>
<input id="cb1" tabindex="1" type="checkbox" onclick="chk1()">
<input readonly class="inp">
</span>
</p>
<p>
<div class="dsc">label event works here</div>
<span class="box2">
<label for="cb2" onclick="Opchk()">
<em>label</em>&larr;</label>
<input id="cb2" tabindex="2" type="checkbox" onclick="chk2()">
<input readonly class="inp">
</span>
</p>
</form></body>
<script>
var itags = document.getElementsByTagName('input');
function Opchk(){
if (typeof window.opera != "undefined"){setTimeout(chk2,10)}}
function chk1(){
if (itags[0].checked == true){itags[1].value = "checked"}
else{itags[1].value = ""}
}
function chk2(){
if (itags[2].checked == true){itags[3].value = "checked"}
else{itags[3].value = ""}
}
</script>
</html>
Here's an example w/ a workaround (maybe unnecessary?):
<html><head>
<style>
body{background:#fff;color:#000;text-align:center}
.inp{border:1px solid #fff;color:#000}
.dsc{color:#444;font-size:smaller;margin-bottom:10px}
.box1{border:3px double green;padding:6px}
.box2{border:3px double blue;padding:6px}
em{color:red}
</style>
</head><body>
- Opera browser -
<form>
<p>
<div class="dsc">must click checkbox for event</div>
<span class="box1">
<label for="cb1">
<em>label</em>&larr;</label>
<input id="cb1" tabindex="1" type="checkbox" onclick="chk1()">
<input readonly class="inp">
</span>
</p>
<p>
<div class="dsc">label event works here</div>
<span class="box2">
<label for="cb2" onclick="Opchk()">
<em>label</em>&larr;</label>
<input id="cb2" tabindex="2" type="checkbox" onclick="chk2()">
<input readonly class="inp">
</span>
</p>
</form></body>
<script>
var itags = document.getElementsByTagName('input');
function Opchk(){
if (typeof window.opera != "undefined"){setTimeout(chk2,10)}}
function chk1(){
if (itags[0].checked == true){itags[1].value = "checked"}
else{itags[1].value = ""}
}
function chk2(){
if (itags[2].checked == true){itags[3].value = "checked"}
else{itags[3].value = ""}
}
</script>
</html>
Comment