|
-
Catfish
using javascript for external html files?
Ok, this is rather strange to explain, but I know a lot of you people here know javascript, so hopefully you'll have some experience. I couldn't find a good free web host that would let me do custom CGI news/content scripts, so at first I tried to do pure HTML (I also don't know CGI yet, lol!). Finding a mistake in something like the menu, made me rather angry as I had to go and fix it in each html file (BTW, I use a text editor for my webpages).
So, I went and made an external javascript file and wrote the html code into it by using the document.write command. I did this for the menu, and one for the header. Then I just imported them into the html files using a <script src="foo.js">. It works fine, as I just have to alter the javascript file now if I need to change my menu. But I've been wondering. Is this bad practice to have content like the menu and header relying on javascript? My other option would be to use frames, but I'm not too giddy about frames.
Here's the site if you want to look. I have hardly any content, and it overall sucks IMHO, so I'm going to be redoing it from scratch soon. I'm also going to be ditching the hardware site feel, as that's kinda overdone anyways: http://fakuban.cjb.net/
(OT, but so many people confuse java with javascript! One of my friends told me they were taking javascript out of Windows XP, gah!!!!)
-
Ursus Arctos Moderatis
Are you familiar with SSI commands? That would be the better way to go.
-
Catfish
No, I'm not familiar with them. Could you explain them briefly? Now I feel like a n00b, .
-
Ursus Arctos Moderatis
-
Catfish
Whoa, thanx! That's just what I needed. Now I guess I really am a n00b, lol!
-
Yea SSI is the solution to all your troubles, would be much easier than making a .js file for each part of your page you want to import. All you do is make your menu and header or whatever you want to import in a serparate .html file, then use <!--#INCLUDE VIRTUAL="file.html" --> to bring that file into your webpage. It's good to have the include inside a table. Not sure what OS your host is but with unix you have to use .shtml unless otherwise configured.
------------------
html.dataraq.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|