firefox and _self

Discussion in 'Javascript' started by pbx, Mar 6, 2007.

  1. pbx

    pbx Guest

    if I try:

    window.open(url, "_self");

    in firefox (2.0x), firefox just refreshes the current window, it
    doesn't "goto" the url.

    this works fine in IE 6 or 7.

    anyone know what the deal is or a suitable workaround?
     
    pbx, Mar 6, 2007
    #1
    1. Advertising

  2. pbx

    Walton Guest

    On Mar 6, 1:38 pm, "pbx" <> wrote:
    > if I try:
    >
    > window.open(url, "_self");


    don't use window.open here. if you want to change the url of the
    current page and not open a new one i would use the location object.

    location.href=url
     
    Walton, Mar 6, 2007
    #2
    1. Advertising

  3. pbx

    pbx Guest

    On Mar 6, 12:14 pm, "Walton" <> wrote:
    > On Mar 6, 1:38 pm, "pbx" <> wrote:
    >
    > > if I try:

    >
    > > window.open(url, "_self");

    >
    > don't use window.open here. if you want to change the url of the
    > current page and not open a new one i would use the location object.
    >
    > location.href=url


    seems to work on IE but not Firefox.
     
    pbx, Mar 6, 2007
    #3
  4. pbx

    Walton Guest

    On Mar 6, 2:33 pm, "pbx" <> wrote:
    > On Mar 6, 12:14 pm, "Walton" <> wrote:
    >
    > > On Mar 6, 1:38 pm, "pbx" <> wrote:

    >
    > > > if I try:

    >
    > > > window.open(url, "_self");

    >
    > > don't use window.open here. if you want to change the url of the
    > > current page and not open a new one i would use the location object.

    >
    > > location.href=url

    >
    > seems to work on IE but not Firefox.


    save this to a file and try it in firefox.

    <html>
    <head>
    </head>
    <body>
    <input type="button" onclick="location.href='http://www.google.com'"
    value="google"/>
    </body>
    </html>

    is working for me.
     
    Walton, Mar 6, 2007
    #4
  5. pbx

    pbx Guest

    On Mar 6, 12:37 pm, "Walton" <> wrote:
    > On Mar 6, 2:33 pm, "pbx" <> wrote:
    >
    > > On Mar 6, 12:14 pm, "Walton" <> wrote:

    >
    > > > On Mar 6, 1:38 pm, "pbx" <> wrote:

    >
    > > > > if I try:

    >
    > > > > window.open(url, "_self");

    >
    > > > don't use window.open here. if you want to change the url of the
    > > > current page and not open a new one i would use the location object.

    >
    > > > location.href=url

    >
    > > seems to work on IE but not Firefox.

    >
    > save this to a file and try it in firefox.
    >
    > <html>
    > <head>
    > </head>
    > <body>
    > <input type="button" onclick="location.href='http://www.google.com'"
    > value="google"/>
    > </body>
    > </html>
    >
    > is working for me.


    me too. but this isn't:

    <html>
    <head>
    </head>
    <body>
    <form>
    <input type="button" onclick="location.href='http://www.google.com'"
    value="google"/>
    <button onclick="location.href='http://www.google.com'">google 2</
    button>
    </form>
    </body>
    </html>

    the second button that is. 2nd button doesn't work in firefox but
    works fine in IE. do you know why?

    (my button mark up is being generated by ASP.NET)
     
    pbx, Mar 6, 2007
    #5
  6. pbx

    Randy Webb Guest

    pbx said the following on 3/6/2007 5:35 PM:

    <snip>

    > <form>
    > <input type="button" onclick="location.href='http://www.google.com'"
    > value="google"/>
    > <button onclick="location.href='http://www.google.com'">google 2</
    > button>
    > </form>
    > </body>
    > </html>
    >
    > the second button that is. 2nd button doesn't work in firefox but
    > works fine in IE. do you know why?


    A BUTTON element has a default type of SUBMIT, IE gets it wrong, and
    with it as a child of the form it is submitting the form when you click it.

    > (my button mark up is being generated by ASP.NET)


    Either have ASP.NET specify it as type="button", move it outside the
    form or add return false to the onclick handler.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Mar 6, 2007
    #6
  7. pbx

    pbx Guest

    On Mar 6, 3:15 pm, Randy Webb <> wrote:
    > pbx said the following on 3/6/2007 5:35 PM:
    >
    > <snip>
    >
    > > <form>
    > > <input type="button" onclick="location.href='http://www.google.com'"
    > > value="google"/>
    > > <button onclick="location.href='http://www.google.com'">google 2</
    > > button>
    > > </form>
    > > </body>
    > > </html>

    >
    > > the second button that is. 2nd button doesn't work in firefox but
    > > works fine in IE. do you know why?

    >
    > A BUTTON element has a default type of SUBMIT, IE gets it wrong, and
    > with it as a child of the form it is submitting the form when you click it.
    >
    > > (my button mark up is being generated by ASP.NET)

    >
    > Either have ASP.NET specify it as type="button", move it outside the
    > form or add return false to the onclick handler.
    >
    > --
    > Randy
    > Chance Favors The Prepared Mind
    > comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
    > Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/


    yes, it pretty much looks like a submit...

    you can't easy move the mark up outside of the form, but for others
    wondering you can use a HtmlInputButton control to generate a correct
    (input style) button.
     
    pbx, Mar 6, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Koen
    Replies:
    2
    Views:
    1,343
    Scott G.
    Jun 28, 2004
  2. Rez
    Replies:
    2
    Views:
    3,838
  3. =?Utf-8?B?bWdkZXY=?=

    ASP.NET 2.0 <base target=_self />

    =?Utf-8?B?bWdkZXY=?=, Apr 16, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    1,109
    =?Utf-8?B?bWdkZXY=?=
    Apr 17, 2007
  4. Joe Kovac
    Replies:
    5
    Views:
    1,540
    Mark Rae
    May 4, 2007
  5. J Kester
    Replies:
    0
    Views:
    303
    J Kester
    Dec 23, 2003
Loading...

Share This Page