javascript url

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

    #1

    javascript url

    What I've been trying to do is this:

    <a href="javascrip t:thisFunction( ); return false;">Do This</a>

    It doesn't work, so I'm doing this:

    <a href="javascrip t:void();" onclick="thisFu nction(); return false;">Do
    This</a>

    And I'm not even sure if I'm doing the void properly. Is there a way to
    accomplish this without using the void ?

    Later, Art.

  • Mick White

    #2
    Re: javascript url

    Art X wrote:
    [color=blue]
    > What I've been trying to do is this:
    >
    > <a href="javascrip t:thisFunction( ); return false;">Do This</a>
    >
    > It doesn't work, so I'm doing this:
    >
    > <a href="javascrip t:void();" onclick="thisFu nction(); return false;">Do
    > This</a>
    >
    > And I'm not even sure if I'm doing the void properly. Is there a way to
    > accomplish this without using the void ?
    >[/color]



    <a href="nonJavasc riptPage.html;"
    onclick="thisFu nction(); return false;">
    Do This
    </a>

    Comment

    • David Dorward

      #3
      Re: javascript url

      Mick White wrote:[color=blue]
      > <a href="nonJavasc riptPage.html;"
      > onclick="thisFu nction(); return false;">
      > Do This
      > </a>[/color]

      Or better:

      <a href="JS-failed.html" onclick="return thisFunction()" >

      where thisFunction() has a suitable return statement.

      This lets you deal with circumstances such as a function that uses W3C DOM
      to dynamically add content. It would fail in Netscape 4 and IE 4, but a
      plain return false wouldn't, so such users would get nothing (except JS
      errors).

      --
      David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
      Home is where the ~/.bashrc is

      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: javascript url

        David Dorward <dorward@yahoo. com> writes:
        [color=blue]
        > <a href="JS-failed.html" onclick="return thisFunction()" >
        >
        > where thisFunction() has a suitable return statement.
        >
        > This lets you deal with circumstances such as a function that uses W3C DOM
        > to dynamically add content. It would fail in Netscape 4 and IE 4, but a
        > plain return false wouldn't, so such users would get nothing (except JS
        > errors).[/color]

        Well, if you have errors, the exection will never reach the "return
        false", and the link would be followed anyway :)

        Still, it's a good suggestion, as it allows the function to decide,
        gracefully, to have the link followed.

        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        • Art X

          #5
          Re: javascript url

          So in any case I should have the actual page (or an alternate) in the
          link ?

          Thanks for the help, I appreciate it.

          Later, Art.

          Comment

          • David Dorward

            #6
            Re: javascript url

            Art X wrote:

            What is the context of this message? Please quote relevent material! :)
            [color=blue]
            > So in any case I should have the actual page (or an alternate) in the
            > link ?[/color]

            Yes. If you attach JavaScript to a link and do not want the user to be
            directed to another page when they click on said link, then set the value
            of the href to a page suitable for users for whom the JS does not function
            correctly (which, in an ideal world, usually means duplicating the client
            side code on the server.).


            --
            David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
            Home is where the ~/.bashrc is

            Comment

            Working...