I have:
<script>
jQuery(document).ready(function(){
$("#mydiv").click(function(){
$("#content").load("html/page.php");
});
});
</script>
And inside of an image map:
<div id="mydiv"><area shape="rect" coords="318,122,413,221" href="#"/></div>
开发者_如何学编程
Another version of the line before:
<area shape="rect" coords="318,122,413,221" href="#" id="mydiv"/>
These (both versions of the image map line) work in all my browsers but in Safari (5.0.5). When in Safari I click but nothing happens. A regular link works so there's nothing wrong with the image map.
I've tried deleting the # in href, and then it works for Safari but not for the rest. If I delete the whole href="#" what happens is that I go back to not working in Safari and working for the rest
Anyone have an idea on what to do for the click to work in all browsers?
Thanks a lot
It won't fix your problem, but you might want to change jQuery(document).ready(function(){
to $(function(){
. It does exactly the same thing.
Regarding your problem, have you tried stepping through with the debugger? This will help you find out if the click handler is being triggered.
If it's the contents of the href attribute causing problems, you could try putting "/" in rather than "#"? Obviously, this will give different behaviour when JavaScript is disabled. What do you want to happen when JS is disabled?
Also, area must have an ancestor map element. Does it?
It might help if you bind the click handler to the area itself, rather than its parent.
精彩评论