Results 1 to 4 of 4

Thread: Adding OnClick tag to all <A HREF> on Joomla

  1. #1
    Join Date
    Mar 2010
    Posts
    372

    Adding OnClick tag to all <A HREF> on Joomla

    I have a small company website built in Joomla and I would like to add a "onClick" wherever <A HREF> tag occurs on the Joomla pages. For this I am using Javascript. However everytime I try it, I am unable to do so. Can you help me out in this matter?

    HTML Code:
    <script type="text/javascript" language="javascript">
    	var getLink = document.getElementsByTagName("a");
    	alert("Found: " + getLink.length + " links");
    	for(var x = 0; x < getLink.length; x++) {
    		getLink[x].onclick = "fgetexit=false";
    	}
    </script>

  2. #2
    Join Date
    Nov 2008
    Posts
    1,192

    Re: Adding OnClick tag to all <A HREF> on Joomla

    HTML Code:
    <script type="text/javascript" language="javascript">
     for(var x=0; x < document.links.length; ++x)
     {
       document.links[x].onclick=function(){fgetexit=false};
      }
     
    </script>

  3. #3
    Join Date
    Mar 2010
    Posts
    372

    Re: Adding OnClick tag to all <A HREF> on Joomla

    Sorry void but that to didn't worked. The output of your code completely changes from what I wanted. Is there anyone else who can suggest me some other ideas? It would be of great help!

  4. #4
    Join Date
    Nov 2008
    Posts
    1,192

    Re: Adding OnClick tag to all <A HREF> on Joomla

    Change your current code:

    HTML Code:
    <script type="text/javascript">
    window.addEvent('domready', function() {
    	new myMenu($E('ul.menutop'), {
    		bgiframe: false,
    		delay: 500,
    		animate: {
    			props: ['width', 'opacity'],
    			opts: {
    				duration:600,
    				fps: 200,
    				transition: Fx.Transitions.Sine.easeOut			}
    		}
    	});
    });
    </script>
    <script type="text/javascript" language="javascript">
     for( var x=0; x < document.links.length; ++x)
     {
       document.links[x].onclick=function(){fgetexit=false};
      }
    </script>
    to something like below:
    HTML Code:
    <script type="text/javascript">
    window.addEvent('domready', function() {
    	for( var x=0; x < document.links.length; ++x)
    	{
    		document.links[x].onclick=function(){fgetexit=false};
    	}
    	new myMenu($E('ul.menutop'), {
    		bgiframe: false,
    		delay: 500,
    		animate: {
    			props: ['width', 'opacity'],
    			opts: {
    				duration:600,
    				fps: 200,
    				transition: Fx.Transitions.Sine.easeOut			}
    		}
    	});
    });
    </script>

Similar Threads

  1. IE7 href + onclick - both happen
    By Ucchal in forum Software Development
    Replies: 5
    Last Post: 24-05-2010, 03:58 PM
  2. Dynamic HREF on onClick
    By hounds in forum Software Development
    Replies: 6
    Last Post: 13-05-2010, 11:53 PM
  3. onClick - change href
    By Neutrals in forum Software Development
    Replies: 6
    Last Post: 12-05-2010, 09:25 AM
  4. A Href And OnClick Button
    By Endowed in forum Software Development
    Replies: 5
    Last Post: 11-05-2010, 10:24 PM
  5. Cancel href via an onclick
    By Doshi1 in forum Software Development
    Replies: 5
    Last Post: 11-05-2010, 10:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,968,378.47852 seconds with 17 queries