Anchor link around input button

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

    Anchor link around input button

    Hey, I know of two ways to place a link on an HTML page; (1) use the
    anchor element, and (2) use javascript to respond to an event (such as
    onclick) and set the location.

    I recently started using anchors more, and I eventually happened to
    try to put an anchor link around an input button, as you can see:

    <a href="example.c om"><input type="button" value="Example" /></a>

    This worked fine in Firefox and Chrome, but it doesn't have any effect
    in IE (you can push the button, but nothing happens). Why is this, how
    can I fix it, and should I just stick with the javascript method as
    shown below:

    <input type="button" value="Example" onclick="locati on.href =
    'example.com';" />

    Thanks.
  • Nik Coughlin

    #2
    Re: Anchor link around input button

    "bgold12" <bgold12@gmail. comwrote in message
    news:3e0d0bf5-ffaf-435e-810f-278f5104e510@b3 1g2000prb.googl egroups.com...
    Hey, I know of two ways to place a link on an HTML page; (1) use the
    anchor element, and (2) use javascript to respond to an event (such as
    onclick) and set the location.
    >
    I recently started using anchors more, and I eventually happened to
    try to put an anchor link around an input button, as you can see:
    >
    <a href="example.c om"><input type="button" value="Example" /></a>
    >
    This worked fine in Firefox and Chrome, but it doesn't have any effect
    in IE (you can push the button, but nothing happens). Why is this, how
    can I fix it, and should I just stick with the javascript method as
    shown below:
    >
    <input type="button" value="Example" onclick="locati on.href =
    'example.com';" />
    Why do you want to turn buttons into links? If you just want your links to
    look like buttons, then why don't you style them that way?

    Comment

    • richard

      #3
      Re: Anchor link around input button

      On Mon, 3 Nov 2008 19:48:43 -0800 (PST), bgold12 <bgold12@gmail. com>
      wrote:
      >Hey, I know of two ways to place a link on an HTML page; (1) use the
      >anchor element, and (2) use javascript to respond to an event (such as
      >onclick) and set the location.
      >
      >I recently started using anchors more, and I eventually happened to
      >try to put an anchor link around an input button, as you can see:
      >
      ><a href="example.c om"><input type="button" value="Example" /></a>
      >
      >This worked fine in Firefox and Chrome, but it doesn't have any effect
      >in IE (you can push the button, but nothing happens). Why is this, how
      >can I fix it, and should I just stick with the javascript method as
      >shown below:
      >
      ><input type="button" value="Example" onclick="locati on.href =
      >'example.com'; " />
      >
      >Thanks.
      A standard button is a link if done correctly. Which won't work if JS
      is off.
      If ya want to do it your way, create an image that looks like a button
      and then use anchors. Works with JS off or on.

      Comment

      • Swifty

        #4
        Re: Anchor link around input button

        richard wrote:
        A standard button is a link if done correctly. Which won't work if JS
        is off.
        However, unless I've missed some trick, the resulting URL will have at
        least a trailing "?". This may be browser-specific, but I don't think so.

        --
        Steve Swift


        Comment

        • Jonathan N. Little

          #5
          Re: Anchor link around input button

          Swifty wrote:
          richard wrote:
          >A standard button is a link if done correctly. Which won't work if JS
          >is off.
          >
          However, unless I've missed some trick, the resulting URL will have at
          least a trailing "?". This may be browser-specific, but I don't think so.
          >
          The lesson here is use a *link* for a *link*, not a form control...

          --
          Take care,

          Jonathan
          -------------------
          LITTLE WORKS STUDIO

          Comment

          • Jukka K. Korpela

            #6
            Re: Anchor link around input button

            Swifty wrote:
            richard wrote:
            >A standard button is a link if done correctly. Which won't work if JS
            >is off.
            >
            However, unless I've missed some trick, the resulting URL will have at
            least a trailing "?". This may be browser-specific, but I don't think
            so.
            It's not browser-specific. And "richard" is of course wrong as usual, with
            just enough factoids accidentally included to confuse many people.

            A button as such is not even a pseudolink. When wrapped inside a form, it
            somewhat corresponds to a link. Using the button resembles then following a
            link to the URL in the action attribute of the form, _except_ that you lose
            most of the functionality of links.

            The trailing "?" is not a problem since it is ignored by servers unless you
            do something extravagant to make them treat it in some special way.
            Actually, "?" followed by a string is ignored if the server has not been
            programmed or configured handle it.

            If you use method="POST" in the <formtag, the "?" won't be appended, but
            who cares?

            --
            Yucca, http://www.cs.tut.fi/~jkorpela/

            Comment

            • Chris F.A. Johnson

              #7
              Re: Anchor link around input button

              On 2008-11-04, bgold12 wrote:
              Hey, I know of two ways to place a link on an HTML page; (1) use the
              anchor element, and (2) use javascript to respond to an event (such as
              onclick) and set the location.
              >
              I recently started using anchors more, and I eventually happened to
              try to put an anchor link around an input button, as you can see:
              >
              ><a href="example.c om"><input type="button" value="Example" /></a>
              Why do you need a button? You can style the link to look like one:

              <a href="example.c om"
              style="backgrou nd: #ddd; color: black; border: 2px outset #555">
              Example</a>
              This worked fine in Firefox and Chrome, but it doesn't have any effect
              in IE (you can push the button, but nothing happens). Why is this, how
              can I fix it, and should I just stick with the javascript method as
              shown below:
              >
              ><input type="button" value="Example" onclick="locati on.href =
              'example.com';" />

              --
              Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
              =============== =============== =============== =============== =======
              Author:
              Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

              Comment

              • Swifty

                #8
                Re: Anchor link around input button

                Jukka K. Korpela wrote:
                The trailing "?" is not a problem since it is ignored by servers unless
                you do something extravagant to make them treat it in some special way.
                Actually, "?" followed by a string is ignored if the server has not been
                programmed or configured handle it.
                >
                If you use method="POST" in the <formtag, the "?" won't be appended,
                but who cares?
                Just in case anyone is curious, a CGI script is passed the URI in the
                environment variable REQUEST_URI.

                I have some webpages that use that value to build other links to the
                same page, but with optional parameters.

                So starting with http://server.com/page that submits a form to the same
                URL with ACTION=GET, I end up with the URI being http://server.com/page?
                If I now use this to build links with parameters, by appending "?parms"
                to the URI value then I end up duplicating the "?". After a few passes,
                I can end up with several "?"s in a row. Of course, it is easy to work
                around this, but finding a way to stop the "?" getting into the browsers
                Location: field in the first place would be the best in many ways.
                Especially as a way of stopping the email from people with nothing
                better to do than ask me why my URL's sometimes have an "?" on the end.
                And yes, I have had such mail. With sufficient users, you eventually get
                asked every conceivable question. I suppose eventually I'll receive the
                complete works of Shakespeare, as a mistype.
                See http://www.swiftys.org.uk/wiz?487

                --
                Steve Swift


                Comment

                • dorayme

                  #9
                  Re: Anchor link around input button

                  In article <scidnQCR6Oe-P43UnZ2dnUVZ8vW dnZ2d@brightvie w.com>,
                  Swifty <steve.j.swift@ gmail.comwrote:
                  I suppose eventually I'll receive the
                  complete works of Shakespeare, as a mistype.
                  See http://www.swiftys.org.uk/wiz?487
                  Why do you suppose this and yet quote something that suggests otherwise?

                  --
                  dorayme

                  Comment

                  • Swifty

                    #10
                    Re: Anchor link around input button

                    dorayme wrote:
                    >I suppose eventually I'll receive the
                    >complete works of Shakespeare, as a mistype.
                    >See http://www.swiftys.org.uk/wiz?487
                    >
                    Why do you suppose this and yet quote something that suggests otherwise?
                    I can see both sides of the argument. That's the advantage of being
                    two-faced.

                    --
                    Steve Swift


                    Comment

                    • dorayme

                      #11
                      Re: Anchor link around input button

                      In article <rZOdnfsmtZw33I zUnZ2dnUVZ8uqdn Z2d@brightview. com>,
                      Swifty <steve.j.swift@ gmail.comwrote:
                      dorayme wrote:
                      I suppose eventually I'll receive the
                      complete works of Shakespeare, as a mistype.
                      See http://www.swiftys.org.uk/wiz?487
                      Why do you suppose this and yet quote something that suggests otherwise?
                      >
                      I can see both sides of the argument. That's the advantage of being
                      two-faced.
                      OK, but my complaint is you being three-faced. You see, if you had
                      suggested both things at the same level of suggestion, that would be two
                      faced. But that is not what you did. You supposed one thing openly, you
                      suggested another thing and, because of the relations between the
                      suppositon and the suggestion, a third thing was borne at another level.
                      I don't think you realise how evil you are. <g>

                      --
                      dorayme

                      Comment

                      Working...