Jump to content

Safari onClick Alternative Using Jquery


cesarcesar

Recommended Posts

After much research i understand that Safari isn't able to call the onClick Event like the other browsers do. So how do i get Safari to act like the other browsers is my question? I have see no real alternative. Can any of you help? My current code is below. It works in all browsers except Safari (haven't checked Chrome, but it should be same as Safari what i read). Thanks much.

 

<script language="Javascript">
<!--

$(document).ready(function() {
        $('.create_project').click(function(){
		alert('its working');
	});
});

//-->
</script>

 

a href="javascript:void(0);" class="create_project"><img src="b.create.off.gif" width="99" height="45" border="0" id="Image51" onMouseOver="MM_swapImage('Image51','','b.create.on.gif',1)" onMouseOut="MM_swapImgRestore()">

Link to comment
Share on other sites

Try it this way and see if it works for you. The onMouseOver/Out events are properties of the a element not the img element so I moved those. Also your link didnt have a closing </a>.  You shouldn't have to worry about how Safari handles click events since the jQuery core code is set to compensate for differences based on the browser being used.

 

Also I would remove the mouse events from the link and just use css to swap the image on hover.  It is also possible that they are causing an issue in regards to safari not triggering the jQuery click function correctly.

 

<script language="Javascript">
<!--

   $(document).ready(function() {
           $('.create_project').click(function(){
               alert('its working');
               return false;
      });
   });

//-->
</script>

 

 

<a href="#" class="create_project" onMouseOver="MM_swapImage('Image51','','b.create.on.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="b.create.off.gif" width="99" height="45" border="0" id="Image51" ></a>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.