Home > Web Front-end > JS Tutorial > body text

Implementation method of JavaScript calling events of Activex control_javascript skills

WBOY
Release: 2016-05-16 18:29:43
Original
1146 people have browsed it

Write it like this:


This method is called when the onXXXevent() event of the acitveX control is triggered.

It would be okay if it were only one and a half, but dozens of such functions fill up my page. Moreover, in VS2008, "Set selected content formatting" always prompts: "The operation could not be completed."
So I want to use another way to replace this kind of writing. At the very least, I can put it in in a separate js file.

Copy code The code is as follows:

VBScript implementation is very strange
sub activex_onXXXevent()
' Processing specific content
end sub

I don’t understand.
Copy code The code is as follows:



Oh, this method can be perfectly implemented and can be placed in a JS file. VS2008 can also support it.
By the way, record the content of attachEvent
In recent work, the attachEvent method has been used. This method can attach other processing events to a certain event. Sometimes it may be useful. Here is a summary of its basic usage.
For its syntax, you can view the "DHTML Manual", which has detailed instructions. Here is an example, which comes from the Internet:
Copy code The code is as follows:

document.getElementById("btn").onclick = method1;
document.getElementById("btn").onclick = method2;
document. getElementById("btn").onclick = method3;

If written like this, only medhot3 will be executed
Written like this:
Copy code The 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 order is method3->method2->method1

If it is the Mozilla series, this method is not supported, and you need to use addEventListener
Copy the code The 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 order is method1->method2->method3
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template