URL link using Button not working in IE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ravey@alum.mit.edu

    URL link using Button not working in IE

    I would like to use a Form "button" (or "input", either one) within an
    anchor, instead of using text or creating a graphic. This works fine
    in all browsers but IE, but IE, while showing the correct URL in the
    status line and the tooltip, DOESN'T initiate the link.

    The code is essentially:

    <a href="http://foo.com/whatever.htm">
    <input type="button" value="Click Me"></a>

    Works fine in Mozilla, Opera, etc., but not in IE. Any ideas?

    Don

  • Thor Kottelin

    #2
    Re: URL link using Button not working in IE



    ravey@alum.mit. edu wrote:[color=blue]
    >
    > I would like to use a Form "button" (or "input", either one) within an
    > anchor, instead of using text or creating a graphic.[/color]
    [color=blue]
    > The code is essentially:
    >
    > <a href="http://foo.com/whatever.htm">
    > <input type="button" value="Click Me"></a>[/color]

    <form action="http://foo.com/whatever.htm">
    <input type="submit" value="Click Me">
    </form>

    Thor

    --

    Comment

    • dwight.stegall@gmail.com

      #3
      Re: URL link using Button not working in IE

      <input type="button"
      onclick="window .location='http ://www.google.com/'">

      break frames
      <input type="button"
      onclick="top.wi ndow.location=' http://www.google.com/'">

      new window
      <input type="button" onclick="window .open('http://www.google.com/')">

      Comment

      • dwight.stegall@gmail.com

        #4
        Re: URL link using Button not working in IE

        doing it that way will put a "?" on the end of the url when you arrive
        at the page. best to use the javascript way to avoid it.

        <input type="button" onclick="window .location='http ://www.google.com/'">

        Comment

        • Lauri Raittila

          #5
          Re: URL link using Button not working in IE

          in comp.infosystem s.www.authoring.html, dwight.stegall@ gmail.com wrote:[color=blue]
          > doing it that way will put a "?" on the end of the url when you arrive
          > at the page. best to use the javascript way to avoid it.[/color]

          What exactly does it hurt?
          [color=blue]
          > <input type="button" onclick="window .location='http ://www.google.com/'">[/color]

          And if user has JS disabled?
          This

          <form action="http://example.com/">
          <input type="submit" value="Click Me"
          onclick="window .location='http ://example.com/';return false;">
          </form>

          is only little better. You need to check if windows.locatio n is allowed.
          I don't know how.

          Anyway, making link look like button is stupid:



          --
          Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
          Utrecht, NL.
          Support me, buy Opera:

          Comment

          • Andy Dingley

            #6
            Re: URL link using Button not working in IE

            On 8 Jun 2005 15:02:58 -0700, dwight.stegall@ gmail.com wrote:
            [color=blue]
            >doing it that way will put a "?" on the end of the url[/color]

            So what?
            [color=blue]
            >when you arrive at the page.[/color]

            Where you eventually arrive depends on what the server wants to do.
            [color=blue]
            >best to use the javascript way to avoid it.[/color]

            Wrong.

            Comment

            • laurence

              #7
              Re: URL link using Button not working in IE


              <ravey@alum.mit .edu> wrote in message
              news:1118263405 .635684.114810@ o13g2000cwo.goo glegroups.com.. .[color=blue]
              >I would like to use a Form "button" (or "input", either one) within an
              > anchor, instead of using text or creating a graphic. This works fine
              > in all browsers but IE, but IE, while showing the correct URL in the
              > status line and the tooltip, DOESN'T initiate the link.
              >
              > The code is essentially:
              >
              > <a href="http://foo.com/whatever.htm">
              > <input type="button" value="Click Me"></a>
              >
              > Works fine in Mozilla, Opera, etc., but not in IE. Any ideas?
              >
              > Don[/color]

              In answering the actual question you put, rather than questions you didn't
              put, my suggestion is this:

              Briefly, in the IE event model, events bubble upwards through the document
              hierarchy. They are first received by the element upon which the event
              occurred. If not handled, they bubble up through the hierarchy until they
              are. There are ways to modify this behaviour.
              In your code, the button is at the bottom of this branch of the hierarchy.
              It recieves the click event, and being a button, handles it. The event does
              not proceed up the chain to the anchor element; the link is not activated. A
              button handles click events automatically, though, until an event-handler is
              explicitly provided to it, does nothing with it.

              NOW it is appropriate to ask why you are bothering to do it this way. As the
              other posts suggest, use a button or a link. There is no need for both.
              HTML-only solutions avoid the pitfalls of disabled script in client.

              Laurence


              Comment

              • John Dunlop

                #8
                Re: URL link using Button not working in IE

                Lauri Raittila wrote:
                [color=blue]
                > [Somebody wrote:][/color]
                [color=blue][color=green]
                > > a "?" on the end of the url[/color]
                >
                > What exactly does it hurt?[/color]

                Tacking a lone '?' to the end of a path creates a new URI
                which by STD66 isn't equivalent to the '?'-less one, though
                it could still be equivalent in the sense that it identifies
                the same resource.

                So, for one, there's (potential) caching implications here,
                because the controller now has two addresses published that
                point to the same location.

                Cheers,

                --
                Jock

                Comment

                Working...