Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

why javascript:

0 views
Skip to first unread message

Lee

unread,
Oct 19, 1999, 3:00:00 AM10/19/99
to
In the example you give, I think it's what's called a "mistake".
No doubt IE allows it, though.

In the context of:

<a href="javascript:newpage()">

where HTML syntax calls for an URL (or URI), it's a protocol
similar to "http:" or "mailto:". The value of the JavaScript
expression becomes the body of the new page. If the expression
evaluates to void, the page remains unchanged. You almost never
see it used with an expression that evaluate to anything except
void (intentionally).


wishbone said:
>
>Hi,
>Why do coders use javascript:(function name) rather than just dropping the
>javascript: , is it just convention or makes the html easier to read?
>onClick="javascript:document.frmEmail.submit()" rather than
>
>onClick="document.frmEmail.submit()"
>
>Thanks.
>
>
>
>
> -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
> http://www.newsfeeds.com The Largest Usenet Servers in the World!
>------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----


wishbone

unread,
Oct 20, 1999, 3:00:00 AM10/20/99
to

Jukka....@hut.fi

unread,
Oct 20, 1999, 3:00:00 AM10/20/99
to
On 19 Oct 1999 16:09:07 -0700, Lee <boy...@worldnet.att.net> wrote:

>In the context of:
> <a href="javascript:newpage()">
>where HTML syntax calls for an URL (or URI), it's a protocol
>similar to "http:" or "mailto:".

Actually, a pseudo-protocol. It's not officially defined and
registered as a URL scheme, see
http://www.w3.org/Addressing/schemes.html

The practical side of the matter is that a page using that pseudo-URL
in links fails miserably when JavaScript is disabled, and even on some
JavaScript-enabled browsers which don't support that hack.

So it's best to use other approaches, such as a valid URL in HREF,
with JavaScript code associated with ONCLICK and other event
attributes. For an example, see the discussion at
http://www.hut.fi/u/jkorpela/forms/javascript.html#window

See also
http://www.irt.org/articles/js169/index.htm#4.12
--
Yucca, http://www.hut.fi/u/jkorpela/
To join the Clueless Club, send a followup to this message
quoting everything up to and including this sig!

0 new messages