I have some odd experience with my browser here. this code below already uploaded to this URL : http://roberthanson.net/index.html
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script src="scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function($) {
$('ul li').click(function() {
$('input#shareto').val($(this).data('val'));
});
});
</script>
</head>
<body>
<form>
<ul>
<li data-val="0-1">
<a href="#" title="" class="selected"><span class="to-admin">Administrator</span></a>
</li>
<li data-val="1-1">
<a href="#" title=""><span class="to-finance">Finance</span></a>
</li>
<li data-val="1-0">
<a href="#" title=""><span class="to-technician">Technician</span></a>
</li>
<li data-val="0-0">
<a href="#" title=""><span class="to-lawyer">Legal</span></a>
</li>
</ul>
<input id="shareto" type="text" value="1-0" name="shareto">
</form>
</body>
</html>
when I open with Microsoft Internet Explorer and Firefox on Linux, those code works perfectly. the value changes based on LI tag clicked. but I don't see this behavior happen on my Mac. All my browser (Safari, Chrome and even Firefox itself) installed on my Mac doesn't give same result as I have on IE or Firefox.
Am I the only one who have this experience? or do we have some extra code to make it works for Mac? thanks before.
Ok, I tried your code, and it doesn't work for me on Chromium on Linux.
The error I get is Unexpected token ILLEGAL on line 12.
I copy pasted your code to vim to check things like bracket matching and other stuff that can cause these issues. upon doing so I saw this in my vim buffer:
`<200b>`
Which is what vim does when it can't render a character. A quick look on Wikipedia shows that U+200b is a ZWSP, or a Zero-Width SPace. I have no idea how an invisible character come into your code, but it seems that JavascriptCore, the Webkit javascript engine doesn't like those characters, but V8 and SpiderMonkey(I think? The FF one anyway) are fine with it.
In short, the fix is to delete the invisible character after the }); at the end of the script block. You can do this the same way you delete any character, you just won't see a difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With