How can I add custom javascript code in the header?

Premium sports magazine Joomla template with clean, easy to customize and unique design.
GK User
Sun Oct 14, 2012 3:10 pm
I want to add the doubleclick (google ads) javascript in the header section of the template. In which file is it located, or where should I put the code in your opinion?
User avatar
Senior Boarder

GK User
Mon Oct 15, 2012 12:48 am
All javascripts are declared in "templates/gk_templatename/layouts/blocks/head.php" with similar code as below.

Code: Select all
$this->addJS($this->URLtemplate() . '/js/gk.scripts.js');

So you can include your js code in a file, copy it to "templates/gk_templatename/js/" folder and add your code in head.php file. Example adding file "myjsfile.js"
Code: Select all
$this->addJS($this->URLtemplate() . '/js/myjsfile.js');


See you around...
User avatar
Platinum Boarder

GK User
Wed Jan 09, 2013 11:50 pm
Hi!

I have the same question, I've already tried your answer copying the .js file in the specified folder. Then added the code line in the head.php in the section where it says "// include JavaScript". Writing it the same way you wrote it produces an error and the webpage won't load. So I tried typing it like other .js files are loaded which is "$this->API->addJS($this->API->URLtemplate() . '/js/myfile.js');"

The problem is that nothing happens. I made a test writing just an alert in jQuery in the .js file but nothing happens. Please help, what I'm doing wrong.

Thanks in advance for your help!
User avatar
Fresh Boarder

GK User
Fri Feb 01, 2013 10:34 am
If you have a link to your site post it here so we can check if js is loading or not.

See you around...
User avatar
Platinum Boarder

GK User
Mon Feb 23, 2015 2:43 am
Hi,
I have the same need/problem. I do everything you said here and its not working.
Are you sure you are not missing anything?

Thanks,
Gorast
User avatar
Platinum Boarder


cron