JavaScript implements methods that pass parameters to setTimeout execution code

  • 2020-05-30 19:25:21
  • OfStack

The example in this article describes how the JavaScript implementation passes parameters to the setTimeout execution code. Share with you for your reference. The specific analysis is as follows:

The setTimeout function is the most critical function in javascript to achieve dynamic effects. However, when I was writing the code yesterday, I found that when the first parameter is a function call, I cannot pass the parameter to the called function. This is really a very serious problem. It took me a long time to find out the problem, which is a waste of time.

Later, I checked online and found that this is actually an BUG of IE. There are a lot of ways to do this, but one of the best is to rewrite the setTimeout function... It's too much trouble. Here is a simple 10-point method. Just add the function{} keyword to the function you want to call.

function ShowMsg(x,y)

This is a convenient way to solve the problem of not being able to pass.

I hope this article is helpful for you to design javascript program.

Related articles: