When referencing other js, its js uses the window. onload event. In this case, the onload event of the introduced page may not be executed. How can this problem be solved? When other js is referenced in the following section, its js uses window. onload event. In this case, the onload event of the introduced page may fail to be executed. How can we run both of them? Besides writing two methods together, there are other methods.
If (window. onload! = Null) {eval ("theOldFun =" + window. onload. toString (); window. onload = function () {theOldFun (); addReadResource ();};}
Functions of eval:
Its function is to parse the corresponding string into JS Code and run
For example, you need to run a variable method.
Function name1 (){......} Function name2 (){......} Var m = "name1"; eval (m + '()'); // run name1 (); m = 'name2'; eval (m + '()'); // run name2 ();