Div onClick not triggering function in Safari

I have HTML code that reads:


<div onClick="javascript:update_status();" class="profile_status" style="cursor: pointer">
<!-- my interesting profile status update here -->
</div>

What’s interesting is that the javascript function update_status() fires in Firefox when I click the div, but in Safari it does not. Any suggestions or ideas?

You don’t need the javascript: in the onclick attribute. An onclick assumes that what follows is a script. I have re-written the snippet below, which now works in all browsers.
<html>

<head>

<script type=“text/JavaScript”>
<!–
function update_status() { alert(“update”); }
//
//–>
</script>
</head>

<body>

<div class=“profile_status” style=“cursor: pointer” onclick=“update_status()”>
<p>aaaaaaa</div>
<!-- end div –>

</body>

</html>

Excellent. I have changed my code accordingly.

I made a slight mistake though… the onclick event isn’t firing in CHROME, not Safari. My bad. Any ideas as to why this wouldn’t fire in Chrome?

Getting same issue; onClick doesn’t seem to work at all :confused:

Is this a Chrome bug? I can’t seem to find anything anywhere else on the Internet about this.

Have you tried typing it correctly as onclick without the capital C. Perhaps Chrome is case sensitive for that command and doesn’t allow you to mistype it with capitals the way other browsers allow in HTML (they all insist on the correct lowercase when you use it in JavaScript).

I left the code alone for a couple of weeks and now the onclick magically works in Chrome without modification. It’s possible that this was a bug.