You need to use absolute (http) or site root relative (leading slash) links.
Also see: http://codex.wordpress.org/Using_Javascript
sorry! what does that mean?
I’m a still little newbie in html
Thanks a lot, i figured out what did you mean. But it didn’t work.
src=”niftycube.js” is a relative link, something that you cannot use with WordPress. Put the http address of your javascript file in here instead.
Can i put a directory in my hard drive instead of an http adress?
Its cause I’m using a dummy wordpress installed on my pc to develop this theme.
You can put the javascript file in your current theme’s folder and then use:
src="<?php bloginfo('template_url'); ?>/niftycube.js"
Oh man! thanks a lot! I couldn’t get to work the rounded corners script but i could with the menu script and thats enough
Thanks a lot!!!
Many thanks from me as well. Spent all morning trying to get my javascript to work in the template, and it is this last tip from “iridiax” that finally sorted it!
To recap (in case there are other beginners like me out there):
in header.php, created after the meta section:
<script type=”text/javascript” src=”<?php bloginfo(‘template_url’); ?>/Scripts/myscriptfile.js”></script>
In the template index.php (somewhere in body between divs, but not in a post in this case):
<script type=”text/javascript”><!–//–>
<![CDATA[//><!–
myfunction(); //–><!]]>
</script>
Ah hah … spotted…
<?php bloginfo('template_url'); ?>
Been looking for a template URL function (well not been looking but waiting to see something for handling it)… 🙂
Not related i know, but helpful to me… 🙂