cesarcesar Posted March 19, 2010 Share Posted March 19, 2010 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 https://forums.phpfreaks.com/topic/195805-safari-onclick-alternative-using-jquery/ Share on other sites More sharing options...
JustLikeIcarus Posted March 25, 2010 Share Posted March 25, 2010 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 https://forums.phpfreaks.com/topic/195805-safari-onclick-alternative-using-jquery/#findComment-1031471 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.