javascript in href or onclick?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • eelco.v987

    javascript in href or onclick?

    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="Valida te('form_commen t_fieldname')"> Validate</amainly
    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="Valida te('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 :)
  • Jim Moe

    #2
    Re: javascript in href or onclick?

    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)

    Comment

    • Eric B. Bednarz

      #3
      Re: javascript in href or onclick?

      "eelco.v987 " <eelco.v987@gma il.comwrites:
      Currently I am using <a href="#foo"
      onClick="Valida te('form_commen t_fieldname')"> Validate</amainly
      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="Valida te('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="Valida te(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

      Comment

      • Rick Merrill

        #4
        Re: javascript in href or onclick?

        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="Valida te('form_commen t_fieldname')"> Validate</amainly
        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="Valida te('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?

        Comment

        Working...