We help IT Professionals succeed at work.

Can I add HTML code to multiple pages at a time?

1,020 Views
Last Modified: 2013-12-24
Hey Experts! I want to be able to "BULK" add html code to a number of pages at the same time. I ahve been told that it cannot be done. Does anyone know of a program or batch file that can edit multiple pages at one time. I have about 150 pages (mostly photos) that I want to add a "no right-click" html code to. Please assist ASAP! Thanks!
Comment
Watch Question

Kiran Paul VJComputer Engineer
CERTIFIED EXPERT

Commented:
what is the code you want to insert? how many lines?
Kiran Paul VJComputer Engineer
CERTIFIED EXPERT

Commented:
you can use dreamweaver to replace a string in all the files in a folder.

Author

Commented:
The code is this (Actually there is also another code for disable image toolbar):
1)

<script language=JavaScript>
<!--
 var message="Copyright 2007 : CorbetDearyPhotos.com";
 function click(z) {
  if (document.all) {
   if (event.button == 2) {
    alert(message);
    return false;
   }
  }
  if (document.layers) {
   if (z.which == 3) {
    alert(message);
    return false;
   }
  }
 }
 if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
 }
 document.onmousedown=click;
// -->
</script>

and 2)

<META
HTTP-EQUIV="imagetoolbar" CONTENT="no">

Author

Commented:
I us FrontPage. I am not a real fan of DreamWeaver. Probably cause I don't know how to use it to its full capability.
Kiran Paul VJComputer Engineer
CERTIFIED EXPERT

Commented:
ok, so you want to insert the new javascript and meta tag in head section right?

if you have dreamweaver do this (i dont have Frontpage in my machine)
open a file from your folder. Change to code view. Press Ctrl+F, Find and replace window will popup. In Find In : Select folder. Then browse for your folder in which your files are stored.
in Search:
select source code
In Find:
type <head>

In Replace paste this

<head>
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<script language=JavaScript>
<!--
 var message="Copyright 2007 : CorbetDearyPhotos.com";
 function click(z) {
  if (document.all) {
   if (event.button == 2) {
    alert(message);
    return false;
   }
  }
  if (document.layers) {
   if (z.which == 3) {
    alert(message);
    return false;
   }
  }
 }
 if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
 }
 document.onmousedown=click;
// -->
</script>



In effect you are adding your meta tag and javascript after the <head>
I am sure a similar feature will be avaible in Frontpage also.

***
And  make sure you backup all files before doing this.
***
CERTIFIED EXPERT
Expert of the Year 2004
Top Expert 2004

Commented:
put the code in an external javascript and name it, e.g. script.js
then define your html pages as a site in frontpage
after that use find and replace option to replace the line before what you want to add these lines, im sure it should be before </head> tag,

so you will find

</head> in all the pages of your site

and replace it with

<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<script type="text/javascript" src="script.js"></script>
</head>

*replace script.js with your own external javascript with the proper location

CAUTION:
make sure that you have a backup of the original pages elsewhere, as replacing is a non-undo thingie
Kiran Paul VJComputer Engineer
CERTIFIED EXPERT

Commented:
you can also create a js file and paste your javascript code there and include the file. This will be better i think, so if there is a change in code, you need to change it only in the js file not in all 150 html files

you can include a javascript like

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

so now the replace code will look like

<head>
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<script type="text/javascript" src="your_file.js"></script>


and the your_file.js will look like

 var message="Copyright 2007 : CorbetDearyPhotos.com";
 function click(z) {
  if (document.all) {
   if (event.button == 2) {
    alert(message);
    return false;
   }
  }
  if (document.layers) {
   if (z.which == 3) {
    alert(message);
    return false;
   }
  }
 }
 if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
 }
 document.onmousedown=click;


Author

Commented:
So I would create a java.js file in notepade or the like, and then add that file to the root of my website. Correct? Then I would put the line of code in each of the pages by using the find and replace command. Is this correct?
Kiran Paul VJComputer Engineer
CERTIFIED EXPERT

Commented:
yes
CERTIFIED EXPERT
Expert of the Year 2004
Top Expert 2004

Commented:
you can use frontpage too to create the js, you just have to save it as a js file;

and its not at all necessary to put the file in the root directory, you can create a separate js folder to keep all your js files there too, just make sure that you give the right path and filename in your code :)

Author

Commented:
FP does not allow me to put in more than one line in the Find and Replace function.
CERTIFIED EXPERT
Expert of the Year 2004
Top Expert 2004
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
> FP does not allow me to put in more than one line in the Find and Replace function.

It does, you have to type <shift>+<enter>.

And the checkbox "Find in source code" has to be checked...
CERTIFIED EXPERT

Commented:
... and the third thing: you can play with Search options to replace the text in each file in your web site.

This is what I am going to do now - replacing minus sign with en-dash in all files... Bye ... :-))

Author

Commented:
FP XP.

Author

Commented:
brundo....sorry but shift enter does NOT work
CERTIFIED EXPERT
Expert of the Year 2004
Top Expert 2004

Commented:
write the code somewhere, and then copy paste in the text box of Replace With
CERTIFIED EXPERT

Commented:
In FP 2003 it works ctrl+enter, too. I don't have FP XP, so I cannot test it there :-((

The third solution is to write your part of code where you want (notepad or a new page in FP) and copy it to the "Replace With" field of the Replace dialog box...

Author

Commented:
Saahil...I tried that too, but when you paste it, it only pastes the 1st line of code. It seems that I am am going to have to invest in a different version of FP. OUCH!
CERTIFIED EXPERT

Commented:
CHRS3000GT and experts who have FP 2003 (as I do),

I've take a look around and I've found how the search and replace dialog box looked like in the FP XP: http://office.microsoft.com/en-us/frontpage/HA010563981033.aspx
In FP 2003 we enjoy more options :-))

CHRS3000GT,

I have two more ideas:

1. Copy your web site somewhere, go to some of your friends who have FP 2003, change what you have to and go back home :-))

2. Do what kiranvj suggested you in his last advice, change each <META HTTP-EQUIV="imagetoolbar" CONTENT="no">

into:

<META HTTP-EQUIV="imagetoolbar" CONTENT="no"><script type="text/javascript" src="your_file.js"></script>

and forget about the line break.

Not very nice, but it works because HTML doesn't see line breaks (in almost all cases).
CERTIFIED EXPERT
Expert of the Year 2004
Top Expert 2004

Commented:
agree with "no line break" option :)

Author

Commented:
Good option....I'll try, brundo!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.