Title: Javascript on pages
Last modified: August 19, 2016

---

# Javascript on pages

 *  [bombora](https://wordpress.org/support/users/bombora/)
 * (@bombora)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-on-pages/)
 * Hey, I’m trying to add a little javascript to my posts but NOT my main page. 
   If I stick it in the header it works fine but it shows up on my index as well,
   so I just want it in the singlepost.php but it doesn’t work there, any help would
   be VERY appreciated 🙂
 * PS I put:
    <script type=”text/javascript” src=”myscript.js”></script>
 * in header.php and it works. I want this to load everytime someone views on my
   posts. Thanks in advance!

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [iridiax](https://wordpress.org/support/users/iridiax/)
 * (@iridiax)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-on-pages/#post-1049813)
 * See: [http://codex.wordpress.org/Using_Javascript](http://codex.wordpress.org/Using_Javascript)
 *  [Len](https://wordpress.org/support/users/lenk/)
 * (@lenk)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-on-pages/#post-1049816)
 * > If I stick it in the header it works fine but it shows up on my index as well
 * Yes because those theme files all call header.php
 * > I just want it in the singlepost.php
 * You could try creating an exact copy of `header.php` – call it something like`
   myheader.php` – and it would contain the javascript you mentioned. Then in `single.
   php` replace…
 * `<?php get_header(); ?>`
 * … with …
 * `<?php include (TEMPLATEPATH . '/myheader.php'); ?>`
 * Also be sure to peruse the docs at the link iridiax gave you.
 *  Thread Starter [bombora](https://wordpress.org/support/users/bombora/)
 * (@bombora)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-on-pages/#post-1049855)
 * Its not working for me 🙁
 * If anyone has another solution to execute some simple javascript when a post 
   is viewed I will owe you forever. And yes I did read through all of those docs
   before starting this thread.
 *  [Len](https://wordpress.org/support/users/lenk/)
 * (@lenk)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-on-pages/#post-1049900)
 * What is it you’re trying to do specifically?
 *  Thread Starter [bombora](https://wordpress.org/support/users/bombora/)
 * (@bombora)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-on-pages/#post-1049932)
 * I’m trying to run a script that pops up when a user goes to my individual pages.
   This informs them that the content is ‘locked’ and they have to contact me to
   unlock it.
 * I use this same script on HTML sites without a problem but am having a really
   tough time with wordpress for some reason 🙂
 *  Thread Starter [bombora](https://wordpress.org/support/users/bombora/)
 * (@bombora)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-on-pages/#post-1049938)
 * Nevermind it appears its working fine in IE but not firefox (and yes I have js
   enabled in ff 😉 ). So I guess its a different issue than I thought, thanks.
 *  [Len](https://wordpress.org/support/users/lenk/)
 * (@lenk)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-on-pages/#post-1049972)
 * Hi bombora. Glad to see you making some progress. Perhaps give the Firebug extension
   for Firefox a shot. One of the things it’s good at is debugging javascripts. 
   Beyond that I’m out of ideas.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Javascript on pages’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 3 participants
 * Last reply from: [Len](https://wordpress.org/support/users/lenk/)
 * Last activity: [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-on-pages/#post-1049972)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
