1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: calling common code

Discussion in 'Web Design & Development' started by Dougj, Mar 17, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. Dougj

    Dougj Thread Starter

    Joined:
    Sep 17, 2002
    Messages:
    324
    I used this once years ago and can't for the life of me remember what it was called or how I did it.

    Since I am using CSS only navigation all my header content is the same so I want to create the page header and nav of my web site once and use it in all my pages. What is the method of calling the code from one page into others??

    D.
     
  2. vipernet

    vipernet

    Joined:
    Aug 22, 2007
    Messages:
    154
    <link href="Whatever.css" rel="stylesheet" type="text/css">
    at the top of your page.


    <?php
    header("Location: list.php");
    ?>

    <?php include(filename.ext); ?>

    in php

    sorry wasn't a 100% sure what u where asking, but hope this helps
     
  3. Dougj

    Dougj Thread Starter

    Joined:
    Sep 17, 2002
    Messages:
    324
    sorry but maybe the CSS reference confused the issue. Basically I have code that is common to all my HTML pages . I would like to create one page with that HTML code and then call that code when required on any or all other pages.


    I am not using php in my pages, just basic html.

    D.
     
  4. Sequal7

    Sequal7

    Joined:
    Apr 14, 2001
    Messages:
    2,382
    Is this a javascript code or an iFrame that you are including on all pages?

    If it is a webpage or database content, you will need to do some server side code to make the includes, this is called Server Side Includes (SSI's)
     
  5. spudster105

    spudster105

    Joined:
    Feb 14, 2008
    Messages:
    6
    one trick i always did was using simple javascript includes

    on your page put:

    Code:
    <script src="FILENAME.js"></script>
    then strip out all the code you want to duplicate for the pages, like the header or nav
    and put it into a file called WHATEVER.js....where whatever would be header or nav ( you get the picture )

    then in that file write this:
    document.write('ALL THAT CODE YOU CUT OUT FROM YOUR PAGE')

    and voila!!

    just make sure that the code on the js page is on one line, very easy to do if you have dreamweaver

    good luck!
     
  6. tomdkat

    tomdkat Trusted Advisor

    Joined:
    May 6, 2006
    Messages:
    7,141
    Were you using a template of some kind?

    Peace...
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/694210