Style

F

Fabian

Lots of people say that

a link (ie href="") should only ever point to another web page, not a
javascript.
a form button should only ever point to a server executable or a post
method

So what is a mutually acceptable trigger for something to activate a
javascript? Or should we just ignore all those people trying to impose
their own style on things?
 
H

Hywel Jenkins

Lots of people say that

a link (ie href="") should only ever point to another web page, not a
javascript.
a form button should only ever point to a server executable or a post
method

So what is a mutually acceptable trigger for something to activate a
javascript? Or should we just ignore all those people trying to impose
their own style on things?

What's wrong with the JavaScript events (on*)?
 
L

Lasse Reichstein Nielsen

Fabian said:
Lots of people say that

a link (ie href="") should only ever point to another web page, not a
javascript.

I concur. The typical behavior associated to a link is fetching the
resource that the link points to. Typical labels of links are nouns
or descriptions: "Cats", "Movies", "My links", "Rocket Science".
a form button should only ever point to a server executable or a post
method

I disagree. Form controls can exist without a form, e.g., in DHTML
applications. The behavior associated with a button is that clicking
it makes something happen. Typical labels on buttons are verbs or
actions: "Go!" "Activate", "Close window", "Energize".

A good sign that using a link is misuse is that you don't know what
to write in the href. Without a href, an <a>-element is no more special
than a <span>. Adding, e.g., href="#" (a href that is never used anyway)
is only to change how the element *looks*, which is really something one
should do with CSS, not HTML.
So what is a mutually acceptable trigger for something to activate a
javascript?

Unless the Javascript fetches a resource (you can write javascript
that emulates a link perfectly), probably a button. Consider what
you would write in the link/on the button.
Or should we just ignore all those people trying to impose
their own style on things?

At your own peril. These rules describe what usability experts have
found that people typically expect. Going against the users'
expectations is rarely a smart move. It just makes the vote with their
feet^H^H^H^Hback button.

/L
 
L

Lee

Fabian said:
Lots of people say that

a link (ie href="") should only ever point to another web page, not a
javascript.
a form button should only ever point to a server executable or a post
method

I don't believe you've heard lots of people say that second line.

The "submit" type of button should only be used to hit the server,
but other buttons were intended to invoke local code, via the
onClick attribute.
 
K

kaeli

Lots of people say that

a link (ie href="") should only ever point to another web page, not a
javascript.

Generally a good practice for browser compatibility. I've seen
exceptions, but they're rare and usually involve non-internet
applications.
a form button should only ever point to a server executable or a post
method

I don't know that I would agree with that. For internet applications,
maybe...but for everything else one can use HTML for, no way.
So what is a mutually acceptable trigger for something to activate a
javascript?

An event (i.e. onClick) of any block element (i.e. table cells, divs,
anchors...).

<a href="SomeNonJSpage.html" onClick="doSomething();return false;">link
text</a>

This allows browsers that have script disabled to still have a
functioning link. Use the link to point to a page that tells them they
need script enabled. This does not work in NN4, which doesn't support
onClick for A.

<div onClick="whatever()">Whatever</div>
This works in most browsers, but not old ones. I *think* it doesn't work
in NN4. 95% of people use IE5 and up. However, you should try to know
your users. You might find out a lot of people come in with Opera or
netscape 4. Site stats are a nice thing.
Or should we just ignore all those people trying to impose
their own style on things?

There's a reason they say stuff - look into the reason and judge for
yourself.


-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
 
T

Thomas 'PointedEars' Lahn

Hywel said:
(e-mail address removed) says...

What's wrong with the JavaScript events (on*)?

Events and event handlers are not restricted to
JavaScript or other implementations of ECMAScript.
They are part of (X)HTML and the DOM of the UA.


PointedEars
 

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

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top