Written as follows:
<SCRIPT type = "text/JavaScript" for = "activexid" event = "onxxxevent ()">
// JS processing specific content.
</SCRIPT>
This method is called when the onxxxevent () event of the acitvex control is triggered.
If you have a half, dozens of such functions fill up my pages. Besides, in vs2008, "setting selected content formatting" always prompts "failed to complete this operation ".
So I want to use another method to replace this writing. At the very least, I can put it in a separate JS file.
CopyCode The Code is as follows: VBScript has a very strange implementation
Sub activex_onxxxevent ()
'Process specific content
End sub
I didn't understand.Copy codeThe Code is as follows: <SCRIPT type = 'text/JavaScript '>
Function onxxxevent (){
// JS content
}
Activexid. attachevent ("onxxxevent", onxxxevent );
</SCRIPT>
Oh, this method can be perfectly implemented, and can be put into a JS file. vs2008 can also support it.
Record the attachevent content by the way
In recent work, the attachevent method is used. This method can append other processing events to an event, which may be useful sometimes. Here we will summarize its basic usage.
For more information about its syntax, see the DHTML manual. Here is an example from the Internet:Copy codeThe Code is as follows: Document. getelementbyid ("BTN"). onclick = Method1;
Document. getelementbyid ("BTN"). onclick = method2;
Document. getelementbyid ("BTN"). onclick = method3;
If this is the case, only medhot3 will be executed.
Write as follows:Copy codeThe Code is as follows: var btn1obj = Document. getelementbyid ("btn1 ");
// Object. attachevent (event, function );
Btn1obj. attachevent ("onclick", Method1 );
Btn1obj. attachevent ("onclick", method2 );
Btn1obj. attachevent ("onclick", method3 );
The execution sequence is method3-> method2-> Method1
If the Mozilla series does not support this method, you need to use addeventlistener.Copy codeThe Code is as follows: var btn1obj = Document. getelementbyid ("btn1 ");
// Element. addeventlistener (type, listener, usecapture );
Btn1obj. addeventlistener ("click", Method1, false );
Btn1obj. addeventlistener ("click", method2, false );
Btn1obj. addeventlistener ("click", method3, false );
The execution sequence is Method1-> method2-> method3