This may be a noob question, but I was wondering if you could link to html code from an html page like you might with javascript. What I want to do is put my navbar in a separate file from my pages so that when I change one, it changes them all. Lets say it looks like this: [COLOR="Red"]index.html:[/COLOR] <html> <head> <title> Title </title> </head> <body> <div class="navbar"> <ul> <li> <a href="http://www.example1.com"> Example1.com </a> </li> <li> <a href="http://www.example2.com"> Example2.com </a> </li> <li> <a href="http://www.example2.com"> Example2.com </a> </li> </ul> </div> <div class="content"> Hello World! </div> </body> </html> Code (markup): but I want it to look something like this: [COLOR="Red"]index.html:[/COLOR] <html> <head> <title> Title </title> </head> <body> [COLOR="Red"]Link to navbar.html[/COLOR] <div class="content"> Hello World! </div> </body> </html> Code (markup): [COLOR="Red"]navbar.html:[/COLOR] <div class="navbar"> <ul> <li> <a href="http://www.example1.com"> Example1.com </a> </li> <li> <a href="http://www.example2.com"> Example2.com </a> </li> <li> <a href="http://www.example2.com"> Example2.com </a> </li> </ul> </div> Code (markup): Thank You so much for any input you can give, thelethargarian
I would recommend using a PHP include, it's not HTML but it's very basic PHP. A little searching and you'll find a pretty simple answer to this issue.
I would also recommend using php as Jongusmoe suggests. First you will need to make sure your hosting server is running php, if so then your all set. In a nutshell, you put all the html you want to include in a file and give it a name, something like "header.php". Every page where you want to include this file also has to have a php extension, so if your home page is index.html for example, you will want to rename it to index.php. Of course, after changing the extension, you will have to update any links pointing your home page. Once this is in place, just use the following snippet of code to include "header.php" <?php include('header.php'); ?> Code (markup): This assumes your header is in the same directory as your index.php. Most people like to make a special folder to store include files. Let's say you store your includes in a directory called "inc" in your root directory. In that case, the include would look like this; <?php include('inc/header.php'); ?> Code (markup): In addition to including a nav bar this way, it's also common practice to include headers, footers, sidebars, or any chunk of code that needs repeated on multiple pages. Once put to practice, this method can save tons of manual updating as your site grows.
Thanks for the replies, but I already know these solutions and have worked with quite a lot of php before. The problem, and sorry for not putting this in the first post, is that there is no php support on my server, so I obviously can't do that. Is there any javascript maybe (I'm not familiar with that and couldn't find anything in a search)? Thanks! thelethargarian
You could include html with javascript, just put in in an external js file using document.write and then call the file wherever you need it, but I would definitely not recommend it for something like your nav bar. What if a user has scripting disabled? Your site would be rendered practically useless without a way to navigate it. Not to mention the accessibility issues, etc. Most web hosts have php installed. If yours does not, I would suggest looking around for a new host.
This is the best way to do it. You have one file for all your pages. Edit: Just saw you have no php support, sorry. You need to switch your host.
Link to my page: /mypage.php?frame=1 /mypage.php?frame=2 /mypage.php?frame=3 the place this action script in the first frame of your movie... p=3;//number of frame in your movie i=1;//counter //use loop while(i<=p) { //set page name variable var pageID="http://mydomain.com/mupage.php?frame="+i; //check referring url if (this._url= pageid){ gotoandstop(i); break; } i++ }
you can use php code like include example <html> <head> <title> Title </title> </head> <body> <?php include "navbar.php"; ?> <div class="content"> Hello World! </div> </body> </html>
Yeah, well, we've already been over this... Thanks anyway. I'll just edit the nav bar on each page separately.
The most commonly used type of link is the stylesheet link:- <link href="style.css" rel="stylesheet" type="text/css"/>
Well, most servers can also support server side includes. This works the same as PHP includes but has a lot more limitations and minor problems. With a certain amount of tweaking you could probably use Server Side Includes (no PHP needed). Unfortunately I don't know much about using SSIs but I'll share what I seem to recall. Most server will only allow SSIs on pages with a .shtml suffix. You could tweak the server to allow SSIs on any html page but for security reasons it might be wise not to do that and instead just make your pages .shtml (there are reasons that servers are setup that way by default so unless you understand those reasons and can address them in some other manner it is recommended not to tweak this). There are also issues with caching due to expires headers or something. I seem to recall that it may be that SSIs don't ever get cached and will re-download on every page view. Obviously you would want you NAV to get cached so it isn't re-downloading every time every page gets viewed. The NAV disappearing and re-downloading every time the user goes to any page of your site is clunky and slow (not to mention the wasted bandwidth). Again though, I believe with some server tweaking the caching issues can also be overcome. If you want to pursue using SSIs then I recommend you spend some time googling and learning all you can about it. Not many people use it (being as PHP and ASP both have equivalent functions without all the shortcomings) so getting good advice on forums regarding SSIs may not be easy, but there are numerous tutorials and how-tos already out there which google should be able to help you uncover. Personally I wouldn't recommend this option.. PHP is by far the best way to go but your server doesn't support PHP. It begs the question though, why doesn't the server have PHP? My guess would be that it is either your own server or a friends server, and you guys just haven't bothered installing and setting up PHP? Or perhaps it is a IIS (Microsoft) server? I ask because it does effect your options. If it's a linux server run by a hosting company, then not having PHP on it is pretty much inexcusable - you should most certainly change hosts. Windows server run by hosting company, again they should have PHP installed, but in this case it is not inexcusable (nor terribly uncommon) for them not too. If you have no choice and must use this server, then you might want to look into ASP, as a IIS server would likely have some form of ASP installed and that should have something which works about the same as PHP includes. However, if you have a choice in the matter, then you should switch to linux based hosting. Unless there is some overwhelming reason why it is imperative that you use a IIS server, linux is by far the better choice (configurability, permissions, stability, documentation, support, etc., etc..) If it is your (or your friends) linux server, then by all means just get PHP set up on the server. SO, in order of preference my recommendation would be: 1) PHP include 2) ASP include - don't know ASP so it may not be called the same thing, but there should be an equivalent). 3) Server Side Include 4) Templates - Like dreaweaver's templating system) 5) Nothing - Just old fashioned editing multiple nav menus on multiple pages (least pleasant option, but better for the users than the remaining options below) 6) Javascript - I wouldn't recommend using document.write though, rather you would want to use DOM methods but I know too little JS to be of any help with that) 7) i-frames - Or regular frames, both have their shortcomings and personally I think the shortcomings of frames or i-frames outweigh the potential benefit unless you are working with a big site with hundreds of pages where having to maintain the navigation system across all those pages is entirely unacceptable (but again, in that situation it is just pretty much essential to find a good host that meets your requirements, which brings us back around to PHP).
External html links are those html link that go to another website...if you place html link to about.com or another web site you like on your web page that would be an example of external HTML....
Others have said. Much easier to use PHP to do this. All you gotta do is rename it to index.php instead of index.html and do this: <HTML> <head> <title> stuff </title> </head> <body> <div class="navbar"> <?php include "navbar.php"; ?> </div> <p> More Stuff </p> </body> </HTML> Code (markup): All the stuff from navbar.html stays the same just rename it to navbar.php and put it (obviously) in the same directory as index.php (formerly index.html). Problem Solved.