Click here to get back home

javascript in href or onclick?

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
javascript in href or onclick? eelco.v987 08-14-2008
Get Chitika Premium
Posted by eelco.v987 on August 14, 2008, 5:26 am
Please log in for more thread options


Hello,
I am buildig a website, which uses javascript for several features
such as fieldvalidation, popupwindows etc.

Currently I am using <a href="#foo"
onClick="Validate('form_comment_fieldname')">Validate</a> mainly
becuase I do not want to openly show the variables in the browser.
In the case of a popup I have this:
<a href="#foo" onClick="Validate('http://www.mysite.com/helpdocs/
donotopen/chapter1/index15.html)">Chapter 1 support</a>
But the thing is, I don't like the #foo as url either.

So I was wondering what's the most common way to call javascript
functions from html as onclick or straight in the href?

thanks for reading and please share your thoughts :)

Posted by Jim Moe on August 14, 2008, 12:54 pm
Please log in for more thread options


On 08/14/08 02:26 am, eelco.v987 wrote:
> Hello,
> I am buildig a website, which uses javascript for several features
> such as fieldvalidation, popupwindows etc.
>
And if javascript is disabled? And if popup windows are disabled?
I'm sure you do not depend on client-side data verification, correct?

> So I was wondering what's the most common way to call javascript
> functions from html as onclick or straight in the href?
>
And if javascript is disabled?
It is quite annoying to visit a site and have the links completely dead
or have no navigation appear at all because it depends on javascript.
Using the pseudo-protocol "javascript:" in href is a bad choice.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)

Posted by Eric B. Bednarz on August 14, 2008, 7:47 pm
Please log in for more thread options



> Currently I am using <a href="#foo"
> onClick="Validate('form_comment_fieldname')">Validate</a> mainly
> becuase I do not want to openly show the variables in the browser.

Come again?
(That’s a rethorical question; but some people around here have
repeatedly announced to happily engage in a wild-goose chase for
undisclosed problems, so stay tuned. :)

> In the case of a popup I have this:
> <a href="#foo" onClick="Validate('http://www.mysite.com/helpdocs/
> donotopen/chapter1/index15.html)">Chapter 1 support</a>
^
It doesn’t help much that you are providing defunct code snippets.

> But the thing is, I don't like the #foo as url either.

<a
href="http://www.mysite.com/helpdocs/donotopen/chapter1/index15.html"
onclick="Validate(this.href)"
>Chapter 1 support</a>

This ‘Validate’ function seems pretty versatile, by the way…

> So I was wondering what's the most common way to call javascript
> functions from html as onclick or straight in the href?

There’s nothing straight about the javascript pseudo protocol. It’s bad
for accessibility, very buggy in Internet Explorer and totally
unnecessary (so for “most common” in the sense of pure quantity you have
a winner here :).

--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011

Posted by Rick Merrill on August 15, 2008, 11:25 am
Please log in for more thread options


eelco.v987 wrote:
> Hello,
> I am buildig a website, which uses javascript for several features
> such as fieldvalidation, popupwindows etc.
>
> Currently I am using <a href="#foo"
> onClick="Validate('form_comment_fieldname')">Validate</a> mainly
> becuase I do not want to openly show the variables in the browser.
> In the case of a popup I have this:
> <a href="#foo" onClick="Validate('http://www.mysite.com/helpdocs/
> donotopen/chapter1/index15.html)">Chapter 1 support</a>
> But the thing is, I don't like the #foo as url either.
>
> So I was wondering what's the most common way to call javascript
> functions from html as onclick or straight in the href?
>
> thanks for reading and please share your thoughts :)

Doesn't javascript have its own 'onclick' tool?

Similar ThreadsPosted
onClick="CallMultipleFns" only invokes first function October 8, 2007, 9:48 am
target or onclick with XHTML 1.1 & Validator XHTML2 October 7, 2004, 1:41 pm
href+#+ie5 September 7, 2004, 4:18 pm
HREF within a FORM April 13, 2005, 9:36 am
HTML table and HREF April 5, 2006, 3:09 pm
Why tag dont have href attribute? April 6, 2008, 9:36 pm
HREF that instructs browser to position doc at END of doc January 20, 2005, 2:34 pm
Calling script form href November 14, 2005, 11:32 am
Does January 4, 2006, 11:46 am
Disabling Anchor Href Tags April 13, 2007, 6:16 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap