Title: Javascript in posts
Last modified: August 18, 2016

---

# Javascript in posts

 *  [zylstra](https://wordpress.org/support/users/zylstra/)
 * (@zylstra)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/)
 * I have the text replace plugin, [http://www.coffee2code.com/archives/2004/06/29/plugin-text-replace/](http://www.coffee2code.com/archives/2004/06/29/plugin-text-replace/),
   installed on my blog. I use it to write javascript into my posts. It works on
   the main page and individual post pages, but it does NOT work on the category
   pages. You can see it not work at EuropeanParty.com. Any ideas?

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

 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-571957)
 * Define not working, do you mean that the js isnt getting loaded?
 * thats probably because your using relative paths when you are inserting the js.
 * and Ive checked, and thats exacly what you are doing:
 * `embed.js`
 * thats relative to what the page being viewed is, so when you are @ [http://www.europeanparty.com](http://www.europeanparty.com)
   then this:
 * [http://www.europeanparty.com/embed.js](http://www.europeanparty.com/embed.js)
 * works.
 * This doesnt, however:
 * [http://www.europeanparty.com/city/cannes/embed.js](http://www.europeanparty.com/city/cannes/embed.js)
 * use the full path the js file.
 *  Thread Starter [zylstra](https://wordpress.org/support/users/zylstra/)
 * (@zylstra)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-571959)
 * whooami, thank you for looking into it, but you are mistaken on two counts. First,
   I am using /embed.js which is absolute. Second, [http://www.europeanparty.com/city/cannes/](http://www.europeanparty.com/city/cannes/)
   doesn’t contain any <script> code in the post code whatsoever.
 *  Thread Starter [zylstra](https://wordpress.org/support/users/zylstra/)
 * (@zylstra)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-571968)
 * Can I offer to pay someone to fix this for me here?
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-571981)
 * actually No you are wrong.
 * ’embed.js’ is NOT an absolute url.
 * Its NO different than calling an image like this:
 * `<img src="blah.png">` **Thats relative to the page being viewed.**
 * THIS is the same code using an absolute url:
 * `<img src="http://www.mydomain.com/blah.png">`
 * [http://www.domain.com/embed.js](http://www.domain.com/embed.js) is absolute.
 * I’ll show you exactly I mean. Please provide EXACTLY what you are putting inside
   the posts you are making. When im done you can feel free to paypal me. 😛
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-571985)
 * actually, I didnt even need you to paste what you are presently doing.
 * Here you are:
 * [http://bigbox.village-idiot.org/](http://bigbox.village-idiot.org/)
 * Thats the front page
 * And now we have:
 * [http://bigbox.village-idiot.org/archives/category/uncategorized](http://bigbox.village-idiot.org/archives/category/uncategorized)
 * Thats inside a category.
 * What am I doing that you are not?
 * Instead of using this inside the post:
 *     ```
       <script>clip = 54;</script>
       <script src="/embed.js"></script>
       ```
   
 * which is using a relative path to embed.js
 * I am using this:
 *     ```
       <script>clip = 54;</script>
       <script src="http://bigbox.village-idiot.org/embed.js"></script>
       ```
   
 * Which is using the absolute url to embed.js
    You can paypal anytime 🙂
 * As I stated above. The path to files is relative to where the browser is.
    For
   instance, in my example above, if I had used the relative path to embed.js the
   server would expect it to be here:
 * [http://bigbox.village-idiot.org/archives/category/embed.js](http://bigbox.village-idiot.org/archives/category/embed.js)
 * Its not. So you use the full url.
 *  [Les Bessant](https://wordpress.org/support/users/lesbessant/)
 * (@lesbessant)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-572003)
 * The forward slash means “the root directory”. So if the path includes the forward
   slash, it is relative to the root of the site, not to the current location. Relative
   to the root is equivalent to an absolute path with the http: and the doamin name.
 * If there is no forward slash, the path _is_ relative to the current location.
 *  [Les Bessant](https://wordpress.org/support/users/lesbessant/)
 * (@lesbessant)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-572011)
 * Zylstra – I believe I have the answer.
 * Your main page and individual post templates (probably index.php and single.php)
   are using [the_content](http://codex.wordpress.org/Template_Tags/the_content)
   and your category page (probably archive.php) is using [the_excerpt](http://codex.wordpress.org/Template_Tags/the_excerpt).
   This shows a small part of the post text _and strips out most tags_.
 * If you edit your archive.php page and change `the_excerpt` to `the_content`, 
   you should see the full content of your posts and your scripts should work.
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-572016)
 * _The forward slash means “the root directory”. _
 * Uh, no it doesnt.
 *  [inmobiliaria](https://wordpress.org/support/users/inmobiliaria/)
 * (@inmobiliaria)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-572017)
 * I think it does
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-572018)
 * well, Ill be damned, I am sorry, you are absolutely correct. Ive tested that 
   and is in fact true. My apologies for being so stubborn.
 *  Thread Starter [zylstra](https://wordpress.org/support/users/zylstra/)
 * (@zylstra)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-572128)
 * LesBessant, to which email address do I send payment? And how much?
 * whooami, glad you see the light! 🙂

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

The topic ‘Javascript in posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 11 replies
 * 4 participants
 * Last reply from: [zylstra](https://wordpress.org/support/users/zylstra/)
 * Last activity: [18 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-posts-4/#post-572128)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
