Forum Moderators: open

Message Too Old, No Replies

Best uses of JavaScript that can best be done by JavaScript?

JavaScript uses

         

MarcMiller

7:59 pm on Sep 19, 2006 (gmt 0)

10+ Year Member



Best uses of JavaScript that can best be done by JavaScript?

Hi
I am a want to be professional web page designer. Have been studying HTML and CSS intensely. Have studied some JavaScript too but not nearly as intensely. I am having trouble seeing many good uses for JavaScript. I know you can use it for form validation which is a good use. However roll overs and even pop-ups seem to be best handled with CSS. I read an article on writing JavaScript to rewrite your CSS to move Nav from the left to the right under the control of a person viewing a web page however when really would you design a page like that. I have been thinking of moving on to PHP and mySQL even before studying the subject of JavaScript to an intense level. So please give me some guidance as to where you use JavaScript on your pages which can best be done with JavaScript and is not a thing you would design into a page once in a million years.

Very truly
Marc

Bddmed

8:51 pm on Sep 19, 2006 (gmt 0)

10+ Year Member



Why don't you ask in the Javascript and Ajax forum?

BTW, I use javascript to display Adsense ads ofcourse ;)

httpwebwitch

2:15 am on Sep 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, CSS "hover" effects have stolen some of javascript's thunder. But it is still your only way to manipulate the DOM and do client-side processing. Do you need to know javascript? It depends if you want to be a no-frills web publisher or a thorough & competent web developer.

javascript is excellent for:

client/browser statistics reporting *
click tracking *
AJAX, anything "load-on-demand" **
manipulating the DOM **
calculators
sniffing for plugins
form validation
other DHTML effects

* = used it on every page I create
** = used often

programming javascript is an essential skill I'd require of any web developer. It's an integral part of the browser, which as a web developer is your primary medium. I'd say a developer who doesn't know javascript is like a painter who doesn't know green.

There are many server-side languages to choose from, but there is only one javascript (which admittedly comes in a few browser flavours).

penders

10:09 am on Sep 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So called 'DHTML' (bit of an historical term) effects are, I guess, almost limitless. But I think it is important to keep in mind that JavaScript is not really the 'presentation layer', that should still be handled by the CSS ideally. For instance, rather than setting a particular style on an element (DIV, Hn, IMG etc...) you should use JavaScript to set/change the class of that element and let CSS do the styling.

Colouring alternative rows in a table...

One 'effect' I have started to use recently, which is great for JavaScript, is simply colouring alternate rows in a table a different colour. You can step through a <table> element and add a class called 'odd' (or something) to every odd row. That class is then defined in your CSS - so presentation is still in the CSS. It then doesn't matter whether you add or remove rows in your table, it will be ok. This function can be very generic so it only ever has to be written once and it will work on any table. Something which is best kept out of server-side scripting (PHP...), since you would have to manually incorporate it into every table you generated. And trying to manually edit your HTML each time is a nightmare.

RonPK

3:10 pm on Sep 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JavaScript is to be used for any on-page behaviour. A client recently asked for a scrolling news ticker, forcing me to dive into the world of marquees. Marquees turned out to s***, so I made my own:

  • all items were put into a list (<ul>), creating semantically correct HTML
  • CSS was used for presentation, by putting the list items inline
  • JavaScript was used to add behaviour: the thing scrolls and rewinds, and stops onmouseover