[英]how must my javascript look like to run at the end of my ASP.NET page
this code is put at the top of my asp.net page:这段代码放在我的 asp.net 页面的顶部:
function Test(HtmlDocument)
{
}
How can I execute this javascript function at the end of my page?如何在页面末尾执行此 javascript function?
Just invoke the function in <script>
tags immediately before the </body>
tag.只需在
</body>
标记之前的<script>
标记中调用 function。
<html>
<head>
<!-- snip -->
</head>
<body>
<!-- snip -->
<script>
Test(document);
</script>
</body>
</html>
Simply put简单的说
<script>Test(document);</script>
In the end of your html你的 html 到底
Or you can put the function at the bottom of the code without the function declaration或者您可以将 function 放在代码底部,而不需要 function 声明
<script>
Your javascript code here
</script>
The best way to achieve this is using windows.onload.实现此目的的最佳方法是使用 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>
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.当文档完成加载时执行客户端。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.