![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Dec 2008
Posts: 160
OS: Linux Mint
|
Universal Nav Bar?
Hello, the few wepages I've made over the past required me to edit every Nav bar on every page whenever I add or take away a link, or change it in anyway. Is there a way to have an external file, like CSS, where all my pages link up to for the Nav bar?
__________________
bLUE445 |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Moderator: Design
Join Date: Oct 2006
Location: Richmond, B.C.; Canada
Posts: 1,427
OS: Windows XP [Version 5.1.2600] SP3 | Ubuntu Jaunty Jackalope | Windows 7 BETA
|
Re: Universal Nav Bar?
There is a way, but it requires JavaScript (which not every browser supports) or PHP (which not every server supports).
JavaScript: in a .js file: Code:
//dm01's navbar
document.writeln('<div id="left">');
document.writeln('<div id="left-in">');
document.writeln('<ul id=nav-left>');
document.writeln('<li><a href="url">Linky 1</a></li>');
document.writeln('</ul>');
document.writeln('</div>'); //end #left
document.writeln('</div>'); //end #left
//end script
HTML Code:
<script type="text/javascript" src="javascript/menu.js"></script> <div id="noscript"> <p>If you are seeing this message, your JavaScript has been disabled. Please enable JavaScript to see this content. I assure you it is neither annoying nor malicious, unless you consider a menu file to be either.</p> <p>Of course, you could always just use the (unfinished) <a href="sitemap.html">Site Map</a></p> </div> <!--id="noscript"--> in your document: PHP Code:
PHP Code:
Where file.html is a separate document with the markup for the navbar. With this method you do not need a degradation, but if the server won't co-operate you won't be able to use it. You don't need to use any other PHP for this method. There is another way to use PHP, but it screws up more often (just the way PHP is). If the above doesn't work, try: PHP Code:
__________________
![]() Validate your Markup Validate your CSS Notepad++ Please use [html], [php], and [code] when posting code or markup. I do not help by Private Message or e-mail. If for some reason I have over-looked a reply to a thread that I have previously replied to, then send me a message. |
|
|
|
|
|
#4 (permalink) |
|
Moderator: Design
Join Date: Oct 2006
Location: Richmond, B.C.; Canada
Posts: 1,427
OS: Windows XP [Version 5.1.2600] SP3 | Ubuntu Jaunty Jackalope | Windows 7 BETA
|
Re: Universal Nav Bar?
Unless you want to update every page manually every time a change is required, yes. CSS can not handle this operation.
I would use PHP if possible, but the JavaScript method works quite well if PHP is not an option.
__________________
![]() Validate your Markup Validate your CSS Notepad++ Please use [html], [php], and [code] when posting code or markup. I do not help by Private Message or e-mail. If for some reason I have over-looked a reply to a thread that I have previously replied to, then send me a message. |
|
|
|
|
|
#6 (permalink) |
|
Moderator: Design
Join Date: Oct 2006
Location: Richmond, B.C.; Canada
Posts: 1,427
OS: Windows XP [Version 5.1.2600] SP3 | Ubuntu Jaunty Jackalope | Windows 7 BETA
|
Re: Universal Nav Bar?
You put the PHP line where you want the nav bar to be (at the top for a top, left, or right nav bar, and at the end for a bottom nav bar).
The second .html file is just a standard .html file, the PHP inserts the markup directly into the document.
__________________
![]() Validate your Markup Validate your CSS Notepad++ Please use [html], [php], and [code] when posting code or markup. I do not help by Private Message or e-mail. If for some reason I have over-looked a reply to a thread that I have previously replied to, then send me a message. |
|
|
|
|
|
#8 (permalink) |
|
Moderator: Design
Join Date: Oct 2006
Location: Richmond, B.C.; Canada
Posts: 1,427
OS: Windows XP [Version 5.1.2600] SP3 | Ubuntu Jaunty Jackalope | Windows 7 BETA
|
Re: Universal Nav Bar?
Does your server fully support PHP?
Linky?
__________________
![]() Validate your Markup Validate your CSS Notepad++ Please use [html], [php], and [code] when posting code or markup. I do not help by Private Message or e-mail. If for some reason I have over-looked a reply to a thread that I have previously replied to, then send me a message. |
|
|
|
|
|
#9 (permalink) |
|
Registered User
Join Date: Dec 2008
Posts: 160
OS: Linux Mint
|
Re: Universal Nav Bar?
Yes, it does...
And whats Linky? Heres my code btw: HTML Code:
<body> <div id="header"> <div id="logo"> <h1><a href="#">CHRIS</a></h1> <p>Pixil Time</a></p> </div> <!-- end #logo --> <div id="menu"> include(file.html); </div> <!--end #menu --> </div> <!-- end #header --> and the second page HTML Code:
<ul> <li class="first"><a href="#">Home</a></li> <li><a href="#">Image Gallery</a></li> <li><a href="#">Stories</a></li> <li><a href="#">Forums</a></li> <li><a href="#">Contact Us</a></li> </ul>
__________________
bLUE445 Last edited by Blue445; 03-30-2009 at 06:10 PM. |
|
|
|
|
|
#10 (permalink) |
|
Moderator: Design
Join Date: Oct 2006
Location: Richmond, B.C.; Canada
Posts: 1,427
OS: Windows XP [Version 5.1.2600] SP3 | Ubuntu Jaunty Jackalope | Windows 7 BETA
|
Re: Universal Nav Bar?
Try this instead:
PHP Code:
__________________
![]() Validate your Markup Validate your CSS Notepad++ Please use [html], [php], and [code] when posting code or markup. I do not help by Private Message or e-mail. If for some reason I have over-looked a reply to a thread that I have previously replied to, then send me a message. |
|
|
|
|
|
#12 (permalink) |
|
Moderator: Design
Join Date: Oct 2006
Location: Richmond, B.C.; Canada
Posts: 1,427
OS: Windows XP [Version 5.1.2600] SP3 | Ubuntu Jaunty Jackalope | Windows 7 BETA
|
Re: Universal Nav Bar?
Did you <link /> the CSS file to the menu page? Sometimes this may be necessary.
<link rel = "stylesheet" type = "text/css" href="filepath/cssfile.cs"></link>
__________________
![]() Validate your Markup Validate your CSS Notepad++ Please use [html], [php], and [code] when posting code or markup. I do not help by Private Message or e-mail. If for some reason I have over-looked a reply to a thread that I have previously replied to, then send me a message. |
|
|
|
|
|
#14 (permalink) |
|
Moderator: Design
Join Date: Oct 2006
Location: Richmond, B.C.; Canada
Posts: 1,427
OS: Windows XP [Version 5.1.2600] SP3 | Ubuntu Jaunty Jackalope | Windows 7 BETA
|
Re: Universal Nav Bar?
Ah, I think I found it. The secondary file is a complete web page. You have omitted the DocType Declaration, <html>, <head></head>, and <body>. When you add the missing elements, the page should appear correctly formatted.
__________________
![]() Validate your Markup Validate your CSS Notepad++ Please use [html], [php], and [code] when posting code or markup. I do not help by Private Message or e-mail. If for some reason I have over-looked a reply to a thread that I have previously replied to, then send me a message. |
|
|
|
![]() |
| Thread Tools | |
|
|