0


I want to fire script on page only when user triggers proper event. In my case user by button click adds new record to database. I'am able to obtain dynamically created control reference with new record in code behind , I just don't know how from code behind pass it this single time to JavaScript that will fire after page loads.
My script will look like this :

function(id) {
   document.getElementByID(id).focus()
}

I'am using .net framework 1.1
Do you have idea how I can accomplish this task ?

1 Answer 1

1

You need to consider

  1. What is the EventTarget? If you want to wait until the whole page has finished loading, then window is the EventTarget you're looking for because it's the top-most DOM related Object you can reference.
  2. Which event do you want to listen for? Again, if you want to detect page loading, you're listening for load, which is the name of the event.

So, using EventTarget.addEventListener

window.addEventListener('load', function () {
    // code to execute when this handler is invoked
});

Edit: I'm not sure your environment will have window, if it doesn't then you'll probably want the highest Node you can access in your DOM structure.

Sign up to request clarification or add additional context in comments.

2 Comments

I forgot to ad that I'am working on framework 1.1
@user3455363 Maybe this page will help. Please note that since the beginning of April 2014, Windows XP has now reached end of life, the oldest .NET Framework that didn't die with it is version 3.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.