加载页面时这些标准方式调用函数的方式有什么区别?

发布于 2025-01-30 14:53:10 字数 479 浏览 4 评论 0原文

这三种通常调用函数的方式有什么区别? 到处搜索,发现了每个人的单一解释,但没有比较所有这三个与彼此相关的解释。这三个如何比较?

A.
window.onload = lunchgallery();

B.
$(function(){laundinggallery();}

C.
$(window).on('load',function(){laundinggallery();});

如果还有其他标准方法欢迎添加并使比较更全面

我是我意识到$(document).ready(function(){});仅适用于jQuery函数。然而,这个问题的范围是针对一般,标准的,非框架的依赖的JavaScript方法,即在pageload或pageload期间或之后或在网页的使用寿命中调用一个函数的方式)。

Whats the difference between these three ways of normally calling a function?
Searched everywhere and found single explanations of each, but not in a comparison of all these three relatieve to eachother. How do these three compare?

A.
window.onload = LaunchGallery();

B.
$(function(){LaunchGallery();}

C.
$(window).on('load', function() {LaunchGallery();});

If there are other standard ways welcome to add and make the comparison more comprehensive

I'm aware that the $(document).ready(function(){}); is for JQuery functions only. The scope of this question however is for general, standard, non framework dependant Javascript ways of calling a function into existence during, at or after pageload or any other moment during the lifespan of a webpage).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文