Reputation: 5291
this code is put at the top of my asp.net page:
function Test(HtmlDocument)
{
}
How can I execute this javascript function at the end of my page?
Upvotes: 0
Views: 110
Reputation: 8618
The easy way is to drop a script manager on the page (anywhere within the body of the page) then put something like this on the page ...
<script type="text/javascript">
Sys.Application.add_load(function () {
// do your thing
});
</script>
That executes client side when the document has finished loading.
Upvotes: 0
Reputation: 2041
The best way to achieve this is using windows.onload. The event can be used to perform some task as soon as the page finishes loading. Here is an example:
<script type="text/javascript">
function my_code(){
alert(" Alert inside my_code function");
}
window.onload=my_code();
</script>
Upvotes: 0
Reputation: 2499
Or you can put the function at the bottom of the code without the function declaration
<script>
Your javascript code here
</script>
Upvotes: 0
Reputation: 359906
Just invoke the function in <script>
tags immediately before the </body>
tag.
<html>
<head>
<!-- snip -->
</head>
<body>
<!-- snip -->
<script>
Test(document);
</script>
</body>
</html>
Upvotes: 3
Reputation: 3139
Simply put
<script>Test(document);</script>
In the end of your html
Upvotes: 2