Skip to main content
January 24, 2008
Answered

Easily embed js in all previously-existining topics

  • January 24, 2008
  • 2 replies
  • 288 views
My company has put in place a system by which we can track hits to various help topics. So there is a js file on our server that does all the work. However, I need to add a line of script to each of the topics that references this file. Is there an easy way of doing this without going into the True Code for each individual topic? I looked into adding it into the header of the template used by the topics, but I think this might not work; within each individual topic, it is just referencing the template, so it would end up being a reference within a reference.

Any ideas? Thanks!
This topic has been closed for replies.
Correct answer
That's a good idea. I didn't think you could use Replace Em on entire folders and for only files with certain extensions. That will probably work. Thanks!

2 replies

January 24, 2008
Or do a multi-file find and replace (there are multiple threads in these forums that talk about tools). You would probably do something like this...

Find:

</head>

Replace with:

<script language="JavaScript" src="myfile.js"></script>
</head>

Basically, you'd need to find code that's already in every file and replace it with the code you want in every file. Just make sure you're keeping necessary code intact, hence including the </head> tag in the replacement code. Hope this helps,

Ben
January 24, 2008
That's a good idea. I didn't think you could use Replace Em on entire folders and for only files with certain extensions. That will probably work. Thanks!
Captiv8r
Legend
January 24, 2008
Hi CAcademy

Perhaps insert the code into a footer and apply the footer to all topics?

Just a thought... Rick