I have a <label><label/> tag inside <A><A/> tag, the <A> tag has a href that calls a JavaScript function.
The JavaScript fails to call when run under IE, but works a treat on all the others I need it too.
I know this is probably not normal, but I’m looking for a speech reader quick fix to a really old project, so lets not get into the why’s and why not’s. 🙂
I’ve searched and can find no reference as to why this does not work, heres my test code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Label and Links Test For Speech Readers</title>
</head>
<script language="javascript" type="text/javascript">
function onHello()
{
alert("hello");
}
</script>
<body>
<p><b>Label and Links Test For Speech Readers</b></p>
<p>This is a test a patch to an historic application, Tested with Chrome, Firefox, IE & BlackBerry OS-6(similator)</p>
<p>
# TEST 1<br />
<a href="javascript:onHello();">Hello1</a>
<br />Current basic link style, that doesn't work with speech readers
</p>
<p>
# TEST 2<br />
<a href="javascript:onHello();"><label style="cursor:pointer">Hello2</label></a>
<br />Easy fix, but this does not work for IE
</p>
<p>
# TEST 3<br />
<label onclick="javascript:onHello();" style="color: #0000ff; text-decoration: underline; cursor: pointer;">Hello3</label>
<br />More work to fix, but compatible with all noted broswers
</p>
</body>
</html>
Don’t put Javascript in the
href, that is disabled in some browsers under some circumstances, for security reasons.Use the
onclickevent to run code: