Pointers in HTML?

Discussion in 'Web Design and Development (archive)' started by idkew, Feb 20, 2004.

  1. macrumors 68020

    idkew

    Joined:
    Sep 26, 2001
    Location:
    where the concrete to dirt ratio is better
    #1
    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
     
  2. macrumors 65816

    tomf87

    Joined:
    Sep 10, 2003
    #2
    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.
     
  3. thread starter macrumors 68020

    idkew

    Joined:
    Sep 26, 2001
    Location:
    where the concrete to dirt ratio is better
    #3
    i can already do that in bbedit, but i want no updating required for 1,000+ files.
     
  4. macrumors 6502a

    Joined:
    Jul 18, 2002
    #4
    if the server thats delivering the pages supports server side includes you can just use an include statement.

    <-- #include filename //-->
     
  5. thread starter macrumors 68020

    idkew

    Joined:
    Sep 26, 2001
    Location:
    where the concrete to dirt ratio is better
    #5
    thanks, i'll give it a try
     
  6. macrumors 601

    Westside guy

    Joined:
    Oct 15, 2003
    Location:
    The soggy part of the Pacific NW
    #6
    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>
     

Share This Page