Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Web Design & Development Web Design & Development
Search Search
Search for:
Tech Support Guy > > >

Solved: calling common code


(!)

Dougj's Avatar
Dougj Dougj is offline
Member with 324 posts.
THREAD STARTER
 
Join Date: Sep 2002
17-Mar-2008, 10:53 AM #1
Solved: calling common code
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.
vipernet's Avatar
vipernet vipernet is offline
Member with 154 posts.
 
Join Date: Aug 2007
17-Mar-2008, 11:57 AM #2
<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
Dougj's Avatar
Dougj Dougj is offline
Member with 324 posts.
THREAD STARTER
 
Join Date: Sep 2002
17-Mar-2008, 12:10 PM #3
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.
Sequal7's Avatar
Computer Specs
Senior Member with 2,382 posts.
 
Join Date: Apr 2001
Location: Around the corner!
Experience: Including today?
17-Mar-2008, 06:35 PM #4
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)
spudster105's Avatar
spudster105 spudster105 is offline
Computer Specs
Junior Member with 6 posts.
 
Join Date: Feb 2008
Experience: Intermediate
17-Mar-2008, 10:15 PM #5
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!
tomdkat's Avatar
Computer Specs
Trusted Advisor with 7,141 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
18-Mar-2008, 04:35 PM #6
Quote:
Originally Posted by Dougj View Post
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.
Were you using a template of some kind?

Peace...
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑