开发者

how to call .js after page is loaded

开发者 https://www.devze.com 2023-01-16 23:15 出处:网络
i need to call customFormElements.js js function after aspx page is loaded, after submit button is clicked. can i do this and if y开发者_运维知识库es how?

i need to call customFormElements.js js function after aspx page is loaded, after submit button is clicked. can i do this and if y开发者_运维知识库es how?

window.onload option is not good...

i need to call this file after i press submit button becouse aspx ajax library clear my js file logic and i need to reload it again.


Did you find any problem in using both OnClientClick and OnClick events of Button control?. In this case both the handlers will be executed after you click the button. The client Handler(Javascript function) will be executed first then the OnClick server side handler will be executed.


what i am getting is that you want to call a javascript function after your page is loaded for this i think its better to use setTimeout function:

With JavaScript, it is possible to execute some code after a specified time-interval. This is called timing events.

It's very easy to time events in JavaScript. The two key methods that are used are:

* setTimeout() - executes a code some time in the future
* clearTimeout() - cancels the setTimeout()

Note: The setTimeout() and clearTimeout() are both methods of the HTML DOM Window object. The setTimeout() Method Syntax var t=setTimeout("javascript statement",milliseconds);

The setTimeout() method returns a value - In the statement above, the value is stored in a variable called t. If you want to cancel this setTimeout(), you can refer to it using the variable name.

The first parameter of setTimeout() is a string that contains a JavaScript statement. This statement could be a statement like "alert('5 seconds!')" or a call to a function, like "alertMsg()".

The second parameter indicates how many milliseconds from now you want to execute the first parameter.

so just create a javascript function in which use setTimeout to call your desired javascript funciton as set time seconds for that

and u can then call this javascript function on

protected void Page_LoadComplete(object sender, EventArgs e)
{
//call javascript function which contains setTimeout();
}

you can see good example on below link:

http://dotnetacademy.blogspot.com/2010/09/timer-in-javascript.html

http://www.w3schools.com/js/js_timing.asp


Bind a submit event handler to the form so that it executes when the form is submitted. The function will fire before the form is submitted. (Thank you to Stan Rogers)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号