<div>'s

liunx

Guest
I support two small churches websites in N. Missouri. I am limited to 5mb of web space each. I would like to put a javascript scrolling navigation bar I use in one church site into a stylesheet and then load it into a div on each page. Then I would save a 130 - 150 lines of code on each page. Can such a thing be done? Also, at the other church, I would like to do the same with a simple table with navigation buttons and a large jpg image both made into a masthead for each page. Again I could save multiple copies of the same code. Any help greatfully appreciated, I'm rather a newby, but loving typing in changes, refreshing and see it appear like magic

Jimcan't really do that with a stylesheet. But you could into some server side scripting (like PHP) and have your navbar load as an include.You can place JavaScript in external files, just like CSS, but you can't mix the two. For instance, place all the JS functions your site uses in a file called function_lib.js. Place this file in your server space and then link to it properly using the following snippet in the <head> of your HTML document:

<script type="text/javascript" src=http://www.webdeveloper.com/forum/archive/index.php/"/url/to/function_lib.js"></script>

If you really want to save on lines of code, consider converting the site from a table-based layout to CSS and <div>s. If you need help, just post here. Also, a visit to the CSS References thread at the top of this forum is a good idea too.

Generally, you can reduce HTML file sizes by 30 to 60 percent when going from tables to CSS and DIVs, since all the visual formatting information is placed in external CSS files (and Download ed once by the end-user).You can place JavaScript in external files, just like CSS, but you can't mix the two.

It's funny that this should come up right now. I'm actually looking into developing a simple "client-side-includes" scheme that would be a single included js file, but able to unobtrusively pull in additional header/footer/sidebar content and inject it into the document post-load. Wouldn't be much use for us server-side guys, but it could be a lifesaver for some.

For the moment, you can just use an iFrame.*groans* Avoid frames like the plague. Too many accessibility issues. If you're really worried about the 5MB limit, upload smaller images and fewer of them. That's where most of your site's data comes from.
 
Back
Top