Add a simple jquery script to my joomla 2.5 site

Need help with the Administration of your Joomla! 2.5 site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
xbass540
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Jan 22, 2008 2:51 pm

Add a simple jquery script to my joomla 2.5 site

Post by xbass540 » Thu Mar 23, 2017 8:40 pm

i am trying to add some jquery script in my 2.5 web site
i would expect to add some

Code: Select all

< scr.. src="....."></script>
in the index.php file of my template or so but looks like this is not the case.

i read https://docs.joomla.org/Adding_JavaScript but couldn't resolve the way to do it.

Any ideas very welcome.

p.s. i have removed some markup for the forum to let me post this

User avatar
ozneilau
Joomla! Guru
Joomla! Guru
Posts: 872
Joined: Tue Aug 04, 2009 9:05 am
Location: Tasmania, Australia
Contact:

Re: Add a simple jquery script to my joomla 2.5 site

Post by ozneilau » Thu Mar 23, 2017 11:27 pm

Rather than editing index.php directly, it is probably better to use a third party extension or similar to add the script text so that changes aren't overwritten by future updates.

I like EasyScript https://extensions.joomla.org/extension ... easyscript but there are plenty of similar extensions to choose from at https://extensions.joomla.org/category/ ... ntegration

xbass540
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Jan 22, 2008 2:51 pm

Re: Add a simple jquery script to my joomla 2.5 site

Post by xbass540 » Fri Mar 24, 2017 8:26 am

hi,
i can't find any for joomla 2.5, and one i found sourcerer asks for payment for js.
i cant buy it before i try it...

I add <scr... src="js/myjs.js" ></scr....> on the head of my template's index.php and it doesn't "see" it.

also added

<scr.... type="text/javascript" src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/js/myjs.js"></scr....>

a bit further below and also didn't work

xbass540
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Jan 22, 2008 2:51 pm

Re: Add a simple jquery script to my joomla 2.5 site

Post by xbass540 » Fri Mar 24, 2017 8:28 am

the js file is this:

jQuery(document).ready(function() {
alert('test');
});

and i get no console errors

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30892
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Add a simple jquery script to my joomla 2.5 site

Post by Per Yngve Berg » Fri Mar 24, 2017 8:48 am

Do you see the script in the Source Code of the Rendered Page?

What triggers the execution of the script?


Locked

Return to “Administration Joomla! 2.5”