PDA

View Full Version : Pointers in HTML?


idkew
Feb 20, 2004, 04:02 PM
What I want to do is make a few lines of code show up on hundreds of html files, maybe a thousand.

Instead of wiring the code in each html file, i want to just write a one word pointer to the code which resides in a different file. can i do this? just tell me what to look for, i will then look it up. you don;t have to explain it if you don't want.

thanks all

tomf87
Feb 20, 2004, 04:33 PM
Well, if you are on a Unix system, you could use sed to stream through all of the HTML files and change the word to something else. You could change thousands of files in a few seconds.

As for doing it via a script or something, I'm not sure how that would be done.

idkew
Feb 20, 2004, 04:51 PM
i can already do that in bbedit, but i want no updating required for 1,000+ files.

Thirteenva
Feb 20, 2004, 07:01 PM
if the server thats delivering the pages supports server side includes you can just use an include statement.

<-- #include filename //-->

idkew
Feb 20, 2004, 07:18 PM
thanks, i'll give it a try

Westside guy
Feb 20, 2004, 09:58 PM
Another way to do it (although if you have access to server side includes, use that) is to use JavaScript. It can be used to write HTML, using "document.write" or "document.writeln".

The downside to this is if someone has JavaScript disabled, they don't see that part of the page. You can use a "noscript" tag to set alternative text/code for those people.

I sometimes create pages (usually forms) that will not work properly without JavaScript. In those cases I'll usually put a snippet of code near the top of the page (note that I'm using a CSS class named "alert" to make this code stand out - often setting the text to bold and red):

<noscript>
<p class="alert">
You have JavaScript disabled in your browser. Please note that this page requires JavaScript to function properly. You may find some things behave strangely or are not available at all.
</p>
</noscript>