HighDots Forums  

FAQ Topic - I have <a href="javascript:somefunction()"> what ... ? (2008-01-03)

Javascript JavaScript language (comp.lang.javascript)


Discuss FAQ Topic - I have <a href="javascript:somefunction()"> what ... ? (2008-01-03) in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
FAQ server
 
Posts: n/a

Default FAQ Topic - I have <a href="javascript:somefunction()"> what ... ? (2008-01-03) - 01-02-2008 , 06:00 PM






-----------------------------------------------------------------------
FAQ Topic - I have <a href="javascript:somefunction()"> what
.... ?
-----------------------------------------------------------------------

Whatever the rest of your question, this is generally a very bad
use of the javascript pseudo protocol. It was designed so that a
function could return a new document. For example:
` javascript:"<p>Hello</p>" `.
Using it simply to call a function when a link is clicked causes
an error in user agents that do not support javascript, or have
javascript disabled. Instead, use
` <a href="something.html" onclick="somefunction();return false"> `
where something.html is a meaningful alternative. Alternatively,
place the onclick event on another element so that users without
JavaScript aren't even aware that it does anything.

http://www.useit.com/alertbox/20021223.html


--
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers. The sendings of these
daily posts are proficiently hosted by http://www.pair.com.


Reply With Quote
  #2  
Old   
Doug Gunnoe
 
Posts: n/a

Default Re: FAQ Topic - I have <a href="javascript:somefunction()"> what ...? (2008-01-03) - 01-03-2008 , 07:30 AM






On Jan 2, 6:00*pm, "FAQ server" <javascr... (AT) dotinternet (DOT) be> wrote:
Quote:
-----------------------------------------------------------------------
FAQ Topic - I have <a href="javascript:somefunction()"> what
... ?
-----------------------------------------------------------------------

Whatever the rest of your question, this is generally a very bad
use of the javascript pseudo protocol. It was designed so that a
function could return a new document. For example:
` javascript:"<p>Hello</p>" `.
Using it simply to call a function when a link is clicked causes
an error in user agents that do not support javascript, or have
javascript disabled.
The argument here is not valid.

If you do javascript:"<p>Hello</p>" with scripting disabled, it
behaves the same way to javascript:alert('Hello') with javascript
disabled. Which of course, one would expect it to behave the same.

So what is the point? If the point was that those implementing the
javascript specification did not foresee what is alleged to be a
misuse of this by calling a function, then I have to say that cannot
be true, since javascript:"<p>Hello</p>" does the same exact thing
with scripting disabled as calling a function.

If the point was something else, I would appreciate some
clarification.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.