PDA

View Full Version : Javascript Template


crestind
05-27-2008, 02:22 PM
I notice most sites use the .html extension, so am I right to assume that these sites are using Javascript templates? And if so, is this (below) an appropriate and effective way to do so? I would have numerous js links in the page that would be called for.

<html>
<body>
<script src="leftdiv.js"></script>
<script src="rightdiv.js"></script>
<script src="footerdiv.js"></script>
</body>
</html>


Contents of the rightdiv.js file
{
document.write("<div><h1>This is a header</h1><p>This is a paragraph</p><marquee>test</marquee></div>");
}

etc.

I am currently using PHP with the same method above, but that does not seem to be a popular alternative since I see few .php pages. Plus, I can't seem to link outside of the same directory.

Jon Hanlon
05-27-2008, 09:44 PM
You can use JS if you like but the trouble is that your source won't appear when you View Source, so it makes debugging hard.
PHP is better at this.

RysChwith
05-28-2008, 08:26 AM
Also, it'll fail for anyone who doesn't have JavaScript enabled (figures for this vary from 1-in-10 to 1-in-20 people). People whose pages use .html extensions are most likely not using templates at all, or they're using development suite specific ones, like Dreamweaver templates.

I'm with Jon on this: If you want templates, use server-side scripting (PHP, ASP, Python, etc.).

Rys

crestind
05-29-2008, 11:29 AM
Thanks! Also, is it correct to assume that if a page just ends in .php, nothing is being called for, and that is only true when it ends in ?=something

RysChwith
05-30-2008, 08:24 AM
Not necessarily. It could be passing information through session variables.

Rys