Writing Javascript to end of page

Discussion in 'ASP .Net' started by Mark, Nov 18, 2005.

  1. Mark

    Mark Guest

    Hi - I have a component, which sends some Javascript to the page.

    I have a registerclientscriptblock which writes some Javascript which
    when the page is loaded, references a textbox written to the page by the
    component.

    However, my javascript gets written to the page before the components
    javascript, so when my script runs, the textbox being referenced doesn't
    exist yet.

    Is there any way to ensure my script, written by the
    registerclientscriptblock, gets written to the end of the page, after
    all other javascript?

    Thanks, Mark





    *** Sent via Developersdex http://www.developersdex.com ***
    Mark, Nov 18, 2005
    #1
    1. Advertising

  2. Hi,

    You don't need a script at the end of the page, but a script which is
    executed after the page loads:

    window.onload = function() {
    // JavaScript-Code goes here and is executed *after* the page
    loads...
    }

    --
    Karsten Samaschke
    IT-Consulting, IT-Development, IT-Training
    5x MS MVP ASP / ASP.NET, Germany
    Homepage: http://www.ksamaschke.de
    Weblog: http://www.karsan.de
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    My Weblog: http://www.karsan.de
    My Books: http://books.ksamaschke.de
    Karsten Samaschke [MVP], Nov 18, 2005
    #2
    1. Advertising

  3. Mark

    Karl Seguin Guest

    Use RegisterStartupScript instead, which does (and is meant to do) exactly
    what you want :)

    karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/
    http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



    "Mark" <> wrote in message
    news:...
    > Hi - I have a component, which sends some Javascript to the page.
    >
    > I have a registerclientscriptblock which writes some Javascript which
    > when the page is loaded, references a textbox written to the page by the
    > component.
    >
    > However, my javascript gets written to the page before the components
    > javascript, so when my script runs, the textbox being referenced doesn't
    > exist yet.
    >
    > Is there any way to ensure my script, written by the
    > registerclientscriptblock, gets written to the end of the page, after
    > all other javascript?
    >
    > Thanks, Mark
    >
    >
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    Karl Seguin, Nov 18, 2005
    #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. Neo Geshel
    Replies:
    2
    Views:
    3,573
    Versteijn
    Aug 18, 2004
  2. William
    Replies:
    2
    Views:
    1,715
    Kevin Spencer
    Jun 1, 2005
  3. Replies:
    2
    Views:
    346
  4. vunet
    Replies:
    2
    Views:
    179
    vunet
    May 19, 2009
  5. Alexandre Morgaut
    Replies:
    5
    Views:
    763
    Alexandre Morgaut
    Jun 13, 2011
Loading...

Share This Page