SoFunction
Updated on 2025-03-01

Methods to determine whether to use it multiple times

Methods to determine whether to use it multiple times

Updated: September 21, 2014 09:59:08 Submission: whsnow
I believe everyone has used it. It is executed when the window is loaded. How to judge if it is used multiple times? Here is a way to share with you

I believe everyone has used it. It is executed when the window is loaded. How to judge if it is used multiple times? Check out the code below

<script>
function onloadCallback(){
//Todo

}
if () {
var onload_random = 'onload'+();
window[onload_random] = ;
 = function (){
window[onload_random]();
onloadCallback();
};
}
else {
 = function (){
onloadCallback();
};
}
</script> 
  • window
  • onload

Related Articles

  • Javascript Array object usage summary

    An array is a linearly allocated piece of memory that calculates offsets and accesses elements in it through integers. Arrays are very fast data structures, but unfortunately, Javascript does not have data structures like this.
    2009-12-12
  • JavaScript implements a method to display the current date on the title bar

    This article mainly introduces JavaScript to display the current date on the title bar, involving JavaScript operation time and DOM node skills. It is very practical. Friends who need it can refer to it.
    2015-03-03
  • JavaScript achieves time range effect

    This article mainly introduces the time range effect of JavaScript. The sample code in the article is introduced in detail and has a certain reference value. Interested friends can refer to it.
    2021-05-05
  • Implementation of decompilation of WeChat applets

    This article mainly introduces the implementation of decompilation of WeChat applets. The example code is introduced in this article in detail, which has certain reference learning value for everyone's study or work. Friends who need it, please learn with the editor below.
    2020-12-12
  • WeChat applet implements form verification source code

    This article mainly introduces the source code of WeChat applets to implement form verification. The sample code in the article is introduced in detail and has certain reference value. Interested friends can refer to it.
    2022-07-07
  • How to implement snake game based on javascript

    This article mainly introduces how to implement the snake game based on javascript. The example code in the article is introduced in very detailed, which has certain reference value for everyone's learning or work. Friends who need it can refer to it.
    2020-02-02
  • All properties of JavaScript variable Dom object

    This article mainly introduces all the properties of the JavaScript variable Dom object. The example code is introduced in this article in detail, which has certain reference value for everyone's learning or work. Friends who need it can refer to it.
    2020-04-04
  • GoJs Picture Drawing Template Picture Usage Example Detailed Explanation

    This article mainly introduces a detailed explanation of the use examples of GoJs picture drawing template Picture. Friends in need can refer to it for reference. I hope it can be helpful. I wish you more progress and get a promotion as soon as possible.
    2023-04-04
  • WeChat applet implements action-sheet pop-up bottom menu function [with source code download]

    This article mainly introduces the function of the action-sheet pop-up menu in the WeChat applet. It analyzes the usage skills of the action-sheet component pop-up menu in combination with examples, including operation methods such as element traversal, event response and attribute settings, and comes with source code for readers to download and reference. Friends who need it can refer to it.
    2017-12-12
  • Detailed explanation of this pointing problem in JavaScript

    This article mainly introduces the detailed explanation of this pointing problem in JavaScript, helping everyone better understand and use JavaScript. Interested friends can learn more
    2021-02-02

Latest Comments