what is the proper use of javascript?

J

John Salerno

I know a lot of you guys are hardcore about writing proper HTML/CSS, so
I'm curious what you feel Javascript should be used for specifically.
Everyone seems to say not to use it for anything necessary, since it can
be turned off. I know sometimes you can use CSS for certain effects
instead. So what are the real, valid uses of Javascript? Does anybody
think you just shouldn't use it? Or are there other, more advanced uses
of JS that I'm not thinking of?

Thanks.
 
D

dorayme

John Salerno said:
I know a lot of you guys are hardcore about writing proper HTML/CSS, so
I'm curious what you feel Javascript should be used for specifically.
Everyone seems to say not to use it for anything necessary, since it can
be turned off. I know sometimes you can use CSS for certain effects
instead. So what are the real, valid uses of Javascript? Does anybody
think you just shouldn't use it? Or are there other, more advanced uses
of JS that I'm not thinking of?

Thanks.

A real valid use of it would be to create a pop up window, a drop
down menu, in short anything at all that might make the site easy
and pleasant to use. So there is no set of things that can be
defined to be real and valid. Much of the objection to it are
that some people have it off or not on auto for various reasons,
some to do with security.

To take the case of a drop down menu, if javascript is employed,
then at least the primary class "Sweets Recipes" (which drops
down to reveal the different types of sweet recipes) should be a
normal html link that takes you to a page that has, in turn, a
set of links to the different sweets, perhaps with the actual
first recipe there as well and a sub menu to the rest.

The point is that it is not always essential that someone on a
home page should be able - at the click or hover of a mouse and
without leaving the page - be able to see every single little
detail about the rest of the site. If you want people to have
this sort of power, be the judge, but do not suppose it is
necessarily a good thing to do. In fact it can cause mental
confusion to people. "Too many choices".

One can go on and on... I am saying there is no essential answer
to what you are asking. There are all sorts of interesting uses
of javascript. For that, just go and see the javascript
available! The important point is understanding how not to be
reliant on it. I have given one example.
 
B

Ben C

I know a lot of you guys are hardcore about writing proper HTML/CSS, so
I'm curious what you feel Javascript should be used for specifically.
Everyone seems to say not to use it for anything necessary, since it can
be turned off. I know sometimes you can use CSS for certain effects
instead. So what are the real, valid uses of Javascript? Does anybody
think you just shouldn't use it? Or are there other, more advanced uses
of JS that I'm not thinking of?

Use HTML for the content, CSS for the presentation and JS for the
behaviour.

For example, :hover can be used for simple effects, but for complicated
popup menu systems, JS is the better tool for the job.

And as you say remember that people might turn it off. In principle
people can also turn off your CSS too by using user important
stylesheets, but maybe fewer people do in practice.

Examples of "advanced" JS would be web apps like Google Maps and
Microsoft's Outlook web interface.
 
B

Brian Cryer

dorayme said:
A real valid use of it would be to create a pop up window, a drop
down menu, in short anything at all that might make the site easy
and pleasant to use. So there is no set of things that can be
defined to be real and valid. Much of the objection to it are
that some people have it off or not on auto for various reasons,
some to do with security.

To take the case of a drop down menu, if javascript is employed,
then at least the primary class "Sweets Recipes" (which drops
down to reveal the different types of sweet recipes) should be a
normal html link that takes you to a page that has, in turn, a
set of links to the different sweets, perhaps with the actual
first recipe there as well and a sub menu to the rest.

Regarding a drop down menu, this can be done quite successfully using just
css and no JavaScript. Take a look at http://www.grc.com/menu2/invitro.htm.
 
D

dorayme

"Brian Cryer said:
Regarding a drop down menu, this can be done quite successfully using just
css and no JavaScript. Take a look at http://www.grc.com/menu2/invitro.htm.

Yes, that is a very good one as far as I can see. Thanks for
posting this. I would have guessed js would give more flexibility
but I don't know this, I tend not to use any dropdowns... but I
consider it from time to time and clients are always mentioning
such things. People like them!
 
T

Travis Newbury

John said:
I know a lot of you guys are hardcore about writing proper HTML/CSS, so
I'm curious what you feel Javascript should be used for specifically.....

Try google maps without javascript. There is a place and a time for
javascript. Unfortunately no one can agree on what that place and time
is...
 
J

Joe (GKF)

..., I tend not to use any dropdowns... but I
consider it from time to time and clients are always mentioning
such things. People like them!
I wonder if they do? Oh, I know *clients* like them, but I for one get a
bit sick of bits and pieces bobbing up all over the screen whenever I
move the mouse.
 
D

dorayme

Joe (GKF) said:
I wonder if they do? Oh, I know *clients* like them, but I for one get a
bit sick of bits and pieces bobbing up all over the screen whenever I
move the mouse.

Me too. I hate the jumpiness of a lot of them, I think there are
things to be done to make them graceful, but I am no expert on
this.

But I am always tempted to make a horizontal main navigation
(inline) list at top have dropdowns on a home page. It is at the
top where you would tend not to hover a mouse unless serious...
and it can aid the concept of a home page, giving access to a bit
more info about the main parts of the site without leaving the
page. These are are considerations. I reckon it provides minor
thrills to a lot of people besides clients.

I liked the css one recommended earlier. But I worry about it
because it is more complicated than I would normally write and I
sort of hate using what I can't write and fix if something goes
wrong. Must study it further, especially the conditionals that
use "table" for IE6...

Javascript is in a way much more cross-browser friendly (no
tweaking for this or that browser as with css equivalent).
 
N

Nico Schuyt

John said:
I know a lot of you guys are hardcore about writing proper HTML/CSS,
so I'm curious what you feel Javascript should be used for
specifically. Everyone seems to say not to use it for anything
necessary, since it can be turned off. I know sometimes you can use
CSS for certain effects instead. So what are the real, valid uses of
Javascript? Does anybody think you just shouldn't use it? Or are
there other, more advanced uses of JS that I'm not thinking of?

Mainly things to beautify that cann't be done in CSS. Or make navigation or
data input easier for the visitors. Requirement is that the site remains
accessible when JS is disabled.

Also: handling the input of visitors before a request is sent to the server.
That can be necessary te reduce number of requests to the server. Problem is
that it's difficult or impossible to create a fall back procedure.
 
J

Joe (GKF)

But I am always tempted to make a horizontal main navigation
(inline) list at top have dropdowns on a home page.
... I reckon it provides minor
thrills to a lot of people besides clients.
Javascript is in a way much more cross-browser friendly (no
tweaking for this or that browser as with css equivalent).
yes. The horizontal ones are much less intrusive as a rule - except when
I want to change tabs to look at another page - and some of the "css
only with a little bit of something extra for IE" ones are quite
beguiling.
The vertical ones that jump out at you when you move the cursor out of
the way so you can read some text are a right pain.

Dropdowns look good, but I can remember when I thought <marquee> looked
good, and you've only got to look at my site to see I'm design-
challenged, so what do I know.
 
D

dorayme

Javascript is in a way much more cross-browser friendly (no
tweaking for this or that browser as with css equivalent).
yes. The horizontal ones are much less intrusive as a rule - except when
I want to change tabs to look at another page - and some of the "css
only with a little bit of something extra for IE" ones are quite
beguiling.[/QUOTE]

Not sure I am with you about the tabs point? Is there some
interference that happens? Have no experience with css drop downs
and pretty well gave up on js drop downs a long time ago... but I
had some fun with one of those 'el basic' "option" type ones
once... where is it now... ah here:

http://tinyurl.com/ye3n8f

(Not completely sure this version is logically consistent or
otherwise wholly kosher... there is something about the option
code needs improving for sure but I know little about these
things)

(Hey Sid, if you want the Desert Problem, you will have to ask...
and you will see how, besides Rubik's cube, its solution can be
the crowning glory of a simple martian visitor...)
 
D

dorayme

"Brian Cryer said:
Regarding a drop down menu, this can be done quite successfully using just
css and no JavaScript. Take a look at http://www.grc.com/menu2/invitro.htm.

I took another look at this and it is a total mess in iCab
(version 3.0.3) - at least on my machine. Usually very good with
CSS. In IE Mac (perhaps not so surprisingly!) it does not work as
far as dropping down but at least the head links work. It looks
odd that the arrows are there and nothing drops. Perhaps one can
leave them out in the img. You can "talk" to just IE Mac...

I guess "quite successful" could be the case or not depending on
the criteria... Makes me a bit uncomfortable. It is tricky code.
Looks like tight-rope walking. Clever, mind you.
 
E

Ed Mullen

Joe said:
yes. The horizontal ones are much less intrusive as a rule - except when
I want to change tabs to look at another page - and some of the "css
only with a little bit of something extra for IE" ones are quite
beguiling.

Could you expand on this, please? I'm not understanding what problem
you're describing.

--
Ed Mullen
http://edmullen.net
http://mozilla.edmullen.net
http://abington.edmullen.net
We win justice quickest by rendering justice to the other party. -
Mohandas Gandhi
 
J

Joe (GKF)

Not sure I am with you about the tabs point? Is there some
interference that happens?

Just that if I move the mouse pointer over a menu item on the way to
click on a tab in Opera (or FF), the dropdown effect happens. No biggie,
but a minor point in favour of left-sided vertical drop-outs.
 
D

dorayme

See my reply to dorayme. It's no big deal.

Well, Joe, I dunno... I am organising a conference where you can
explain yourself to a big crowd. There will be a rock band and
food, so think positive... It will be a big deal, don't be modest.
 
J

Joe (GKF)

Well, Joe, I dunno... I am organising a conference where you can
explain yourself to a big crowd. There will be a rock band and
food, so think positive... It will be a big deal, don't be modest.
mmmm rock band ... food ...
Maybe it IS a big deal. Yes. The more I think of it, the bigger a deal
it gets...
ummm

That is FREE food, isn't it?
 
D

dorayme

Joe (GKF) said:
mmmm rock band ... food ...
Maybe it IS a big deal. Yes. The more I think of it, the bigger a deal
it gets...
ummm

That is FREE food, isn't it?

O yes mate! No question. But remember, it is a Big Speech you
have to make...
 
B

Brian Cryer

dorayme said:
"Brian Cryer" <[email protected]> wrote:

I took another look at this and it is a total mess in iCab
(version 3.0.3) - at least on my machine. Usually very good with
CSS. In IE Mac (perhaps not so surprisingly!) it does not work as
far as dropping down but at least the head links work. It looks
odd that the arrows are there and nothing drops. Perhaps one can
leave them out in the img. You can "talk" to just IE Mac...

Interesting. I wonder if a pure css menu that works with all browsers is
just pie in the sky at the moment.
I guess "quite successful" could be the case or not depending on
the criteria... Makes me a bit uncomfortable. It is tricky code.
Looks like tight-rope walking. Clever, mind you.

I agree. I use a variation on their code, and the "nasty" bit (or clever bit
depending on your point of view) is that the logic it uses on firefox is
different to that on IE. I think your "tight-rope walking" illustration is
probably quite apt. Where I use it I'm only targeting IE and Firefox, but it
may yet cause me grief with another browser down the line.

Its a different topic really, but As a "pc" developer without access to a
mac, I do wish there was an easy way to test on the various "mac" browsers.
 
D

dorayme

"dorayme"

Its a different topic really, but As a "pc" developer without access to a
mac, I do wish there was an easy way to test on the various "mac" browsers.

There is now a way for Mac users with the latest machines which
also run Windows, the point being that a Windows user could also
have one of these machines instead of just a PC one. But, of
course, it would be an investment hard to justify if you knew you
were not going to use Mac side apart from just seeing what Mac
people get... (I would bet quids this would not actually happen
once you developed a taste!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top