I would like to use Javascript function to realize adding my website to favourites. Firstly, I don't know how to put this function, in standard web pages there is link in the head section, how to realize that in joomla? Secondly, I want to call this function by clicking the link either on text or icon. Please help me how to realize that.
What is that text "somesite.blabla"? I want to put function name there with its arguments. How can I put whole function content in joomla then?
I better explain it by example: In standard html there is link <a href="javascript: function_name('Favourite_name', 'my_website_address')">Add to favourite</a> And I want to put the javascript function "function_name(arg1,arg2)" somewhere in joomla but I don't know how and where to exactly? Normally in standard html/css I create link to javascript file in the head section, that file containing javascript function, or I could insert that function between script tags also in head section. But how to realize that in joomla which based on php?
Or maybe there is another solution for this? Maybe I should convert javascript function into php function and to just call php one? But I think it would be a little silly because its better to realize that on client site than to call function placed on server.
you only insert <a href="#" id="yourid">yourcontent</a> <script type="text/javascript"> jQuery(document).ready(function($){ $("yourid").click(function(){ alert("me"); // you can insert you function here }) } </script>
Thank you for your help. If I insert this code in place where link is going to be so javascript oode with my java script function will probably land in home section unless joomla do this properly and html part put into home section and javascript into right place.
Maybe above solution is all right but I didn't and still don't know how to use it. Where am I to supposed to insert that code? I have found another solution: 1) Icon which adds favourite has link <a hef="javascript:addfavourite('Website_name', 'Website_url')">Link_text</a> 2) In main joomla directory adding file favourite.js with function addfavourite() 3) In template directory in its subdirectory layouts in file template.php in section <head> adding address to file favourite.js as:<script type="text/javascript" src="favourite.js"></script>
I think it is missing closing bracket in this code!!!!! jQuery(document).ready(function($){ $("yourid").click(function(){ alert("me"); }) } There is opening bracket after word "ready". Where is its closing one?