Jump to content

Fixed Header


JaredFish

Recommended Posts

Okay in my effort to convert my site to strict html i hav come accross a problem...I use a header.html in a frame at the top for all my links etc and now i want to get rid of that... is there any way i can use a file fort my header and just import that into my pages all the tym??? If not then how do i turn the frames borders off in my style-sheet?? and are frames even allowed in strict-html??Shot

Link to comment
Share on other sites

There are two ways of achieving this. Either store it in XML and XSLT and execute it with JavaScript or (the better solution in this matter)- use server side includes. The server side language will import the code for the header in every page and that's it. And as far as I know... frames are not allowed in strict XHTML.

Link to comment
Share on other sites

Im not sure bout the server side thing ocz i do most of my editing offline...So... how would i "import" the code from one file to be executed in my page? I haven't done the xml tutorial so if its explained easily there just let me know and i'l do that instead of messin about with html....Shot agen

Link to comment
Share on other sites

Ask your host if PHP, ASP(.NET), ColdFusion or any server side scripting language is supported. This is THE easiest way to do the things. It's actually also the one resulting in best performance in this matter (exeptions may occur if you use server side includes way too much).You can use this code to execute an XML and it's XSLT stylesheet inside an XHTML file. It would take some more time to load then with SSIs though. So it must be used wisely as well. The XSLT itself could contain another copy of the same JavaScript that would execute an inner XML and XSLT and so on, but again: longer rendering.I'm willing to make the XSLT and XML for you if you could give a link to your header page. If you later on decide to add something, you would only have to work inside the XML which is a lot easier than it might sound.

Link to comment
Share on other sites

okay, my site is www.fishonaskateboard.co.nr/index2.htmlits basically 2 frames.. one at the top for the header.html and the other for the content... so if xml will make it easy 2 have the header.html as a header and import it into the main page then pls tel me how...

Link to comment
Share on other sites

I would use php, assuming your server supports it (the vast majority do).then you can just use the php include or require function, e.g. insert the following into your page where the header should go.

<?phpinclude 'header.htm'?>

note that you'll need to save your page as .php instead of .htm/.html. Also note that as your domain will point to an index.htm file this means you'll also need to make an index.htm page with a meta to forward users to the php page. You just make an empty html page with the following in the head:

<meta http-equiv="Refresh"content="1;url=http://www.yourpage.com/index.php">

Link to comment
Share on other sites

Following from my above comment, the advantage to this approach is that the output page is nice clean html that contains no visible scripting. The document the user receives subsitutes the php with the content of header.htm, the php itself is removed from the end file. This makes your site more secure as users can't see your scripts, and means it will all validate as clean html/xhtml.

Link to comment
Share on other sites

This is probably an indication that your server doesn't support PHP. Or... I'm not sure actually. When I was failing trying PHP scripts I saw nothing everywhere a PHP script was used. For example:

Hello. You are <?php echo "welcome"; ?>

Would return "Hello. You are ".Just to ensure: ask your host if he has PHP support. It's really important that we know.You should also try this:

<?php require("header.htm"); ?>

All this SSI does is copy&paste the code from the specified page into the page it's used. Therefore, you must strip your included pages of their heads and bodies (excuse the pun :) ). I'm not sure if PHP scripts are allowed within the imported files.I'll wait a bit before making your header thing (though I could finish it in a few hours or a day mostly). As said above: SSIs are the better method in this matter.

Link to comment
Share on other sites

i can't get the thing to work off my HDD neva mind on the server... but if i can get it working it'l save alot of hassle... i really want to turn my page into strict html...I use freewebtown as my server.. looking on their site atm and can't find if they support php or not... can't find it anywhere... can u maybe send me a basic example of it working and i can upload and check if it works?? it wud be a gr8 help... fishonaskateboard@yahoo.com...

Link to comment
Share on other sites

is it the redirect you are having the problem with? Maybe I didn't explain it properly, here's a complete example of the index.html file you need:

<html><head><title>Redirect</title><meta http-equiv="Refresh" content="1;url=http://www.yourpage.com/index.php" /></head><body><p>You should now be redirected to my website. If the website does not load click <a href="index.php">here</a>.</p></body></html>

That should redirect the user to your php page. If you are still having problems it is probably because your host doesn't have php installed, in which case you are stuck (either get a new host or doen't use php - boen suggested an alternative but more complicated solution earlier).Make sure you have a complete php page as well, such as:

<html><head><title>My Page</title></head><body><?phpinclude ('header.htm')?><p>Page content.</p></body></html>

The header.htm file does not have to be a complete html file, just the content you wish to include, it is effectively pasted into the index.php html in place of everything between the php tags. If you wrote the header.htm file out in proper html you would be pasting close tags in funny places and that would confuse the browser.A note on boen_robots' use of require - require is dangerous for this kind of use as if the page cannot load the require function it will not load any of the page at all. If there is an error with your header.htm (such as the data got corrupted) then it would stop the whole page (infact the whole website as the header will be on every page) from loading. Using include means that if the header.htm file has a problem the rest of the page will still load.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...