Recently, JavaScript has always appeared in front of me. There are many special effects or other Ajax aspects, and we are also studying prototype. js script libraries. However, for me, JS cainiao, there are not many things very well.
Yes. So today I took a look at the tutorial, for our. net Program I am not very familiar with OO programming in JS, so I will study it today.
To learn about the activexobject object in JS, I will summarize other objects in the next few articles.
There is nothing new, and the activexobject object must be declared is no exception, of course, it can return a reference to an automation object,CodeAs follows:
VaR OBJ = new activexobject (servername, typename [, location]);
The following describes the parameters:
OBJ everyone knows that it is a variable, that is, the variable name to be assigned to activexobject;
Servername provides the application name of the object;
The type or class of the object to be created by typename;
Location.
The Automation server provides at least one type of objects. For example, a word processing application may provide application objects, document objects, and toolbar objects. For example, to create an Excel application and sheet object, the Code is as follows:
VaR excelapp = new activexobject ("Excel. application ");
VaR excelsheet = new activexobject ("Excel. Sheet ")
Once an object is created, it can be referenced in the code using the defined object variable. Next we will look at the reference to the object and method through an example, access the attributes and methods of the new object through the object variable excelsheet and other Excel objects, including the Application Object and activesheet. Cells
Set.
The Code is as follows:
1 excelsheet. application. Visible = true;
2 excelsheet. activesheet. cells (1, 1). value = "this is column A, Row 1 ";
3 excelsheet. saveas ("C: \ test. xls ");
4 excelsheet. application. Quit ();
Next let's take a look at how to create an object on the remote server, but there is a premise to disable Internet security. To create an object on a remote network computer, you can pass the name of the computerActivexobjectOfServername
Parameters. The name is the same as the machine name part of the shared name. For example, to share a network named "\ myserver \ public,ServernameYes
"Myserver ". In addition, you can use DNS format or IP address to specifyServername. The following code returns the version number of an Excel instance running on a remote network computer named "myserver:
1 function getappversion (){
2 var xlapp = new activexobject ("Excel. Application", "myserver ");
3 return (xlapp. version );
4}
If the specified remote server does not exist or cannot be found, an error will occur.
the above examples and some instructions are from the tutorial. Due to time issues, I did not go to the example or write the code by myself, because the methods and attributes of activexobject objects are referenced by the
class. I have only used XMLHttpRequest objects, and many other things need to be understood. I should also write some XMLHttpRequest objects in the future.
after all, Ajax is so popular now!