Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Webpages and JavaScript

Reply
Thread Tools

Webpages and JavaScript

 
 
SmilingPolitely
Guest
Posts: n/a
 
      10-24-2005
I have a couple of questions on the use of JavaScript in web pages, that
I would like to open to the forum to discuss...

What are the pros and cons when using JavaScript as a substitute for
<include> for information contained on every page?

e.g.

I have a header in a .js file on every page of my site:
document.write("<a href=\"index.html\">Home<\/a> | ");
document.write("<a href=\"about.html\">About<\/a> | ");
document.write("<a href=\"bio.html\">Biography<\/a> | ");


called by:

<script type="text/javascript" src="header.js"></script>

There has been some discussion around about the use of javascript to do
this, specifically for those browsers and/users that are not JavaScript
enabled.....

but the next problem,

if the browser is not JavaScript enabled and therefore unable to see my
..js headers and footers, then how can I expect them to fill in a form
that is validated using JavaScript?

Is there a way to account for all users and their browsers, or do I aim
somewhere in the middle, html headers and footers but with JavaScript
form validation?


For your consideration.


Scott
 
Reply With Quote
 
 
 
 
mbstevens
Guest
Posts: n/a
 
      10-24-2005
SmilingPolitely wrote:

>
> if the browser is not JavaScript enabled and therefore unable to see my
> .js headers and footers, then how can I expect them to fill in a form
> that is validated using JavaScript?


JavaScript is fine for checking forms client side, but you always need
to do taint checking and further validation server side. Crackers can
easily subvert client side checks.

The client side checks will save a few moments for visitors who have
JavaScript enabled, which is one of the good uses for that technology.


>
> Is there a way to account for all users and their browsers, or do I aim
> somewhere in the middle, html headers and footers but with JavaScript
> form validation?
>


Yes, use server side programming. Perl/CGI (my favorite) or PHP are
common. A few services are also starting to support Python and Ruby.
There are also some monopolized solutions from Mordor$oft, whose names I
shall not utter here. <dog howls in the background> For headers and
footers that repeat on each page, you can use a preprocessor, generate
the pages server side, or use SSI (which is also a way of generating
pages server side).

I believe that many people avoid server side solutions because they
think it will somehow be too hard (it's not), or they don't have
privileges on their host. I can only say -- get a host that allows you
to do server side programming, and start collecting information on
server side programming.
--
mbstevens
http://www.mbstevens.com/preprocessor/
 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      10-24-2005
SmilingPolitely wrote:
> I have a couple of questions on the use of JavaScript
> in web pages, that I would like to open to the forum
> to discuss...


> What are the pros and cons when using JavaScript
> as a substitute for <include> for information
> contained on every page?


Pro. You can skimp on your server.
Con. User agents without JavaScript (such as GoogleBot, Lynx and
whatever browser came with my cellphone) won't get the data.

> if the browser is not JavaScript enabled
> and therefore unable to see my .js headers
> and footers, then how can I expect them to
> fill in a form that is validated using
> JavaScript?


You can't. You should only use JavaScript to make things more
convenient[1] (or perhaps more fun) for users. When it comes to
ensuring information is available, and sanity checking data the user
provides then you MUST do that on the server.

[1] "Oh, you didn't fill in an email address, the server's going to
reject this anyway so I'll save you the round trip" does qualify.

 
Reply With Quote
 
rf
Guest
Posts: n/a
 
      10-24-2005
SmilingPolitely wrote:

> What are the pros and cons when using JavaScript as a substitute for
> <include> for information contained on every page?


Javascript should *add* to a page, not be part of it.

> document.write("<a href=\"index.html\">Home<\/a> | ");


This is navigation. Navigation should *never* be done with javascript. Why
exclude 10% of your viewers and, more importantly, the search engine bots.


--
Cheers
Richard.
 
Reply With Quote
 
Travis Newbury
Guest
Posts: n/a
 
      10-24-2005
SmilingPolitely wrote:
> I have a couple of questions on the use of JavaScript in web pages, that
> I would like to open to the forum to discuss...


Ok

> What are the pros and cons when using JavaScript as a substitute for
> <include> for information contained on every page?


Pro: You can make the page do interesting things.
Con: Not everyone will be able to enjoy it.
Reality: Most people can see it just fine, but you will want to use
caution when using any client scripting.

--
-=tn=-

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading Webpages using javascript Brett Javascript 1 05-29-2005 10:25 AM
Repost: Javascript Rollovers not Refreshing on Dynamic Webpages. John Ortt Javascript 3 11-30-2004 02:03 PM
Javascript Rollovers not Refreshing on Dynamic Webpages. John Ortt Javascript 0 11-25-2004 09:55 AM
ASP.NET Security and Webpages =?Utf-8?B?RGV2aW4=?= ASP .Net 2 06-10-2004 02:10 PM
FireFox and Zooming in/out on pictures on webpages.... Jeff Ingram Firefox 2 05-23-2004 06:38 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57