HELP! Page.RegisterStartupScript not working right in firefox

Discussion in 'ASP .Net' started by Dav, Dec 21, 2006.

  1. Dav

    Dav Guest

    In my ASP.NET codebehind I have the following code to jump to a certain
    section of the page:

    ---
    Dim strAnchorScript As String = "<script language='javascript'>" & _
    "window.location.hash='#" & strLink & "'</script>"

    Page.RegisterStartupScript("anchorScript", strAnchorScript
    ---

    In IE when it loads the page it jumps to a certain section of the page.
    For firefox it just loads the page. But if I refresh the page in
    firefox it jumps to the the section I want.

    So, how do I get this to work in firefox (to use
    Page.RegisterStartupScript and to jump to a certain place on the page)?
    This seems like the easiest way to jump to a certian page.

    Please post your answer here (no emails) and no flames.

    Thanks for you help!
     
    Dav, Dec 21, 2006
    #1
    1. Advertising

  2. Hi,
    I suspect there are some probematic characters in strLink.Try
    escape(strLink) and see if it is working or not.

    Thanks and Regards,
    Manish Bafna.
    MCP and MCTS.

    "Dav" wrote:

    > In my ASP.NET codebehind I have the following code to jump to a certain
    > section of the page:
    >
    > ---
    > Dim strAnchorScript As String = "<script language='javascript'>" & _
    > "window.location.hash='#" & strLink & "'</script>"
    >
    > Page.RegisterStartupScript("anchorScript", strAnchorScript
    > ---
    >
    > In IE when it loads the page it jumps to a certain section of the page.
    > For firefox it just loads the page. But if I refresh the page in
    > firefox it jumps to the the section I want.
    >
    > So, how do I get this to work in firefox (to use
    > Page.RegisterStartupScript and to jump to a certain place on the page)?
    > This seems like the easiest way to jump to a certian page.
    >
    > Please post your answer here (no emails) and no flames.
    >
    > Thanks for you help!
    >
    >
     
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=, Dec 21, 2006
    #2
    1. Advertising

  3. Dav

    Mark Rae Guest

    "Dav" <> wrote in message
    news:...

    > In my ASP.NET codebehind I have the following code to jump to a certain
    > section of the page:
    > Dim strAnchorScript As String = "<script language='javascript'>" & _
    > "window.location.hash='#" & strLink & "'</script>"
    >
    > Page.RegisterStartupScript("anchorScript", strAnchorScript


    Well, the first thing to do is to eliminate your outdated non
    XHTML-compliant script declaration:

    "<script language='javascript'>"

    is deprecated in favour of:

    "<script type='text/javascript'>"

    I'm not saying that will definitely solve it but, when things work in IE and
    not in other browsers, it's almost always because of IE's non-standard
    behaviour.

    > In IE when it loads the page it jumps to a certain section of the page.
    > For firefox it just loads the page. But if I refresh the page in
    > firefox it jumps to the the section I want.


    Second thing to do is to examine the source in IE and FireFox - what's
    different...?

    > So, how do I get this to work in firefox (to use
    > Page.RegisterStartupScript and to jump to a certain place on the page)?
    > This seems like the easiest way to jump to a certian page.


    Yes, it certainly should work. However, might it be that it doesn't work in
    FireFox the first time because of script placement? I.e. is FireFox trying
    to run the code too early, before the whole page has been completely built?
    See here:
    http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21622556.html
     
    Mark Rae, Dec 21, 2006
    #3
    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. Marshal Antony
    Replies:
    2
    Views:
    647
    Marshal Antony
    Dec 1, 2004
  2. jef
    Replies:
    4
    Views:
    1,165
  3. Replies:
    3
    Views:
    5,438
    Neredbojias
    Jan 7, 2006
  4. Dune88

    RegisterStartupScript and Firefox

    Dune88, Feb 13, 2008, in forum: ASP .Net
    Replies:
    5
    Views:
    6,277
    Misliplavo
    Jun 26, 2009
  5. Replies:
    1
    Views:
    726
    Sergey Poberezovskiy
    May 16, 2007
Loading...

Share This Page