在页面完全加载后触发一个函数 [英] fire a function after page completely loaded

查看:67
本文介绍了在页面完全加载后触发一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个登录页面和一个主页。我想在这个页面成功加载后在主页上激活一个函数。

如果我将该函数保留在pageload或其他页面相关的事件上主页的功能是在页面从登录页面重定向到主页时触发。



但是我想要一个不同但却很常见的东西------- ---------

用户点击登录按钮 - >主页出现(没有执行任何功能) - >加载动画将显示带有backgroung disable->在这个时间我的函数应该执行 - >函数执行后加载消息就会消失。



我希望我能让你明白。



请帮忙怎么做。



我知道这不能用页面相关事件来完成。

解决方案

并不是说这个问题与客户端以及完全下载所有内容的时间完全相关,所以这并不重要它是在服务器端,ASP.NET,纯静态HTML文件,或其他任何东西。



确保某些处理完成时的方法之一页面完全加载是使用jQuery,其标准使用风格几乎基于: http:// learn.jquery.com/about-jquery/how-jquery-works [ ^ ]。



注意从处理

(文件).ready



-SA


I have a login page and a home page.I want to fire a function on home page after this page has been loaded successfully.
If I keep the function on pageload or other page related event of home page,the function is firing when the page is redirecting from login to home page.

But I want a different but common thing----------------
User clicks on login button->homepage comes up(with no function execution)->loading animation will show with backgroung disable->in this time my function should execute->after function execution loading message will disappear.

I hope I can make you understand.

Please help how to do this.

I know this can not be done with page related event.

解决方案

Not that this issue it totally related to the client side and the time when all the content is completely downloaded, so it does not really matter what it was on the server side, ASP.NET, plain static HTML file, or anything else.

One of the ways to make sure that some processing is done when the page is completely loaded is using jQuery, with its standard usage style pretty much based on that: http://learn.jquery.com/about-jquery/how-jquery-works[^].

Pay attention for the top-level script starting with handling


(document).ready.

—SA


这篇关于在页面完全加载后触发一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆