• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

Can I add a piece of code to every page in a directory automatically?

In Dreamweaver, I can select some code and replace it with something else directory-wide by choosing the Find In: Folder... option in the Find and Replace box.  Awesome.

Now I need to add a reference to a JavaScript file to every page in my site.  How can I do this?  The line of code is:

<script type="text/javascript" src="/js/offsiteAlerter.js"></script>

It just needs to be anywhere in the <head> of the document.  Is there a way to find the <head> of every page and add it?

Also, I do not have a site defined in Dreamweaver.
  • 2
2 Solutions
why not replace:
<your script reference>
Using dw or and text replace application

mrcoulsonAuthor Commented:
I guess I wanted to keep all of the script tags in one place.  I mean, I'd rather settle for that solution than pasting it manually in a few hundred places tonight.
Jason C. LevineNo oneCommented:

Don't let the perfect stand in the way of the good.  glum's answer is how I would do it...
mrcoulsonAuthor Commented:
Well, heck!  You're a genius, so it must be right!

But it's good advice.  I guess I just want to avoid our new site becoming a jumble of unrelated code like the current site is; however, I ain't makin' no stinkin' overtime here tonight and may as well shorten one task if I can, right??

Thanks, guys!

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now