Now that we've got the installation out of the way, let's jump straight in and create a remote scripting example. The example we're about to create is rather trivial, but never the less it demonstrates the capabilities of remote scripting in both the client and server domains.
Enabling remote scripting on the client side
In order for remote scripting to work properly, it must be "enabled" by both the client (our HTML page) and the server (an ASP page which we will create shortly). Create a new file called client_test.html and save it into the directory above where you installed the remote scripting files. For example, if you installed them to c:\inetpub\wwwroot\_ScirptLibrary then you would save client_test.html to c:\inetpub\wwwroot.
RSEnableRemoteScripting accepts one optional parameter: the directory on the server where it can find rsproxy.class. If no parameter is specified, then it assume that rsproxy.class exists in the _ScriptLibrary directory. We call RSEnableRemoteScripting between a script block, like this:
Because RSEnableRemoteScripting adds an applet to our HTML page, it should be called just after the <body> tag. Note however that this applet isn't visible in the output and isnít shown when you view the pages source in the browser either.
So here's what our client_test.html page looks like so far:
The next thing we want to do is actually implement remote scripting into our HTML page. Add the following code just before the </head> tag:
var strTest = prompt("Enter String To Reverse:");
var objRS = RSGetASPObject("rev.asp");
var objResult = objRS.revStr(strTest);
Also add the following code just before the </body> tag:
Don't worry if you don't understand everything at the moment because it will become clearer as we move on. At this point, all you need to do is have your client_test.html page looking like this: