I have a wordpress site and I'm trying to load a .js file to it. For some reason I can't get it to work.
The js file is at http://www.leadcomm.net/pricequotejs.js
and I put this in the footer:
<script type="text/javascript">
if (window.location.href == 'http://www.leadcomm.net/cost-estimate/') {
var js = document.createElement('script');
js.setAttribute("type","text/javascript");
js.setAttribute("src", "pricequotejs.js");
document.getElementsByTagName("head")[0].appendChild(js);
}
</script>
Any ideas on what I'm doing wrong?
Is there any particular reason you can't use a standard HTML script tag?
this is not the proper manner to use a js file in wordpress. first you need to save your js file in a folder named js on you theme folder. then open your header.php file and use this add this line :
this will load your js file to wordpress website. Happy coding!
I left the document onload function. silly me...