Search code examples
javascriptsafarihref

Javascript href not working in Safari


I have the following code snippet that works on all browsers except for Safari:

<a href="javascript:void (0);" onclick="javascript:myfunction (x,y);"><span>something here </span></a>

How can I make this work in Safari? Any tips are greatly appreciated.


Solution

  • This should work. Use either href or onclick. Using both might be confusing browser which to run. Try running only href="javascript:myfunction (x,y);"