|
Posted by Neredbojias on 06/19/06 01:34
To further the education of mankind, "Jukka K. Korpela"
<jkorpela@cs.tut.fi> vouchsafed:
> Neredbojias <http://www.neredbojias.com/fliam.php?cat=alt.html>
> scripsit:
>
>>> Best solution found::::
>>>
>>> <a href="#" onclick="func();return false">
>>>
>>> This is a handy way to stop the page from jumping around but still
>>> run the function.
>>
>> FYI, another best way is:
>>
>> <a href="javascript:void(0)" onclick="func()">
>
> The first "best solution" is a link to the start of the page, with a
> scripted that overrides the link functionality with the invocation of
> a function, when scripting is enabled. That does not sound quite
> logical to me. A self-referencing link would be slightly more logical
> as well as much more practical when scripting is disabled:
> <a name="foo42" href="#foo42" onclick="func();return false">
In other words, clicking the link with javascript disabled will reload
the page and return the user to the same spot from which he started.
Sounds good.
> Of course, if the sole purpose of the "link" is the scripted event,
> then the link should be dynamically generated using the scripting
> language, so that the link is there if and only if scripting is
> enabled.
I very much agree. Similarly, I've done many pages with, for example,
(pseudo) lists of thumbnail image links. There is no javascript to be
seen in the html per se; any j/s events, etc., are added afterwards by a
link-loop which, of course, does nothing with j/s disabled.
> In that case, you could use href="error.html" where
> error.html is a page that explains that an unexpected error has
> occurred, etc.
>
> Using href="javascript:void(0)" does not conform to any published
> specification, since there is no such spec that defines javascript:
> URLs. Besides, it fails even on some old browsers that do not
> recognize such URLs (or pseudo-URLs), despite supporting JavaScript.
Well, javascript:void is a core javascript construct, and if the browser
supports javascript... Perhaps there is no _specific_ _html_ spec citing
"javascript:void" verbatim, but I hardly consider that a good reason to
avoid it's usage. There is much documentation written regarding this
usage which certainly seems acceptable and valid by all parties
concerned.
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5
_Reference:Operators:Special_Operators:void_Operator
--
Neredbojias
Infinity has its limits.
[Back to original message]
|