A product I recently developed is embedded in Moss. However, since 2007, some JavaScript Functions of Microsoft have been written incorrectly or do not meet our requirements, we need to override these native functions.
For example, there is a native method called mtd1. to overwrite it, the main method is to use window. mtd1 = function {... your logic ....}; but sometimes for some purpose, the loading time of Microsoft JS files will be later than ours. In this way, we cannot normally overwrite this function. The solution to this problem is to use
Window. setTimeout (function ()
{
Window. mtd1 = function {... your logic ....};
},100 );
The above 100 is a time (in milliseconds). In actual use, it will be difficult to control the time. It will vary with network conditions and machine conditions, and it will also be too large to avoid execution too late.
There are still solutions. Let's take a look at the example.
Function setoverridefunction ()
{
If (window. mtd1! = NULL)
{
Window. mtd1 = function {... your logic ....};
}
Else
{
Window. setTimeout (function ()
{
Setoverridefunction ()
},100 );
}
}
Window. setTimeout (function ()
{
Setoverridefunction ();
},100 );
OK, perfect solution ....