[thelist] javascript://

.jeff jeff at members.evolt.org
Tue Jul 3 11:57:48 CDT 2001


winfried,

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Winfried Huslik
:
: Did you ever try:
:      "javascript:;"
: which is a syntactically correct empty
: statement as opposed to
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

syntactically correct, but hard to notice the difference between it and a
javascript protocol that's referencing nothing.

<a
 href="JavaScript:;"
>blah</a>

<a
 href="JavaScript:"
>blah</a>

notice the difference doesn't immediately stand out.

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:      "javascript://"
: which is not, but condoned by browsers
: and sometimes irritating them.   (It calls
: the JavaScript engine without feeding
: anything to it exept a comment not having a
: clearly defined end of statement (no "\r\n"
: or ";").
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

what proof do you have as a basis for this opinion?  what browsers have you
noted this causing an error in?

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: It has IMO the same effect as:
:      "javascript:void(0)"
: but is shorter.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

partially true.  the void() function was introduced  in js1.1.  the
single-line comment (//) was introduced in js1.0.  the latter, obviously,
has a much higher chance of being supported.

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: As mentioned in this list earlier:
:      a href="#"
: should never be used (unless you desire
: the side effects) [...]
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

agree 100% with the caveat that the side effects are never desirable.

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: because it reloads the page (showing the
: top position regardless where your link
: was).
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

it's not an actual reload of the page though.  all variables that have been
assigned values during the course of the page view will remain intact.  the
browser simply scrolls the document to the top of the page -- still not a
desirable effect, imo.

thanks,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/






More information about the thelist mailing list