When you write JavaScript scripts before, events are implemented using the
Object.event = handler;
The way you initialize it. This approach is common to Internet Explorer, Mozilla/firefox, and Opera. One problem, however, is that this approach can only have one event for an event-handling process. It is not good if you want an event to execute multiple processes sequentially.
However, Internet Explorer provides a attachevent method starting at 5.0, which allows you to assign multiple processes to an event. Attachevent is also suitable for the current Opera. But the problem is that Mozilla/firefox does not support this approach. But it supports another AddEventListener method, which is similar to attachevent and is used to assign multiple processes to an event. But the events they assign are somewhat different, in the Attachevent method, the event starts with "on," and in AddEventListener, the event has no "on" at the beginning, and the other AddEventListener has a third parameter, which is typically specified as False is OK.
So if you want to assign multiple processes to an event in your program, just judge the browser first, and then choose to use Attachevent or AddEventListener on a different browser. Examples are as follows:
if (window.attachevent) {
Window.attachevent ("onload", remove);
else if (Window.addeventlistener) {
Window.addeventlistener ("Load", remove, false);
}
function Remove () {
var div = document.getelementbyidx_x ("Divprogressbar");
Document.body.removeChild (DIV);
}
============= or you can use it.
if (document.all) {window.attachevent (' onload ', remove)}//ie
Else{window.addeventlistener (' Load ', remove,false);}//firefox
Note: The sequence of execution of several procedures assigned by attachevent is random, so there is no sequential dependency between these processes. In addition, attachevent and AddEventListener not only apply to window objects, but other objects also support the method. The highest level of programmer: static paralysis, if epilepsy
Original address: https://www.cnblogs.com/demonxian3/p/6374388.html