Here's what I've tried so far - it doesn't work. (it's telling me
there's a ";" missing in the "<body onload..." line)
I've created a function named ConnectSocket that is called from the
onload event to replace the Sub Window_Onload in the vbscript version.
Similarly, I created the CloseSocket function (called from the
onunload event) to replace the Window_OnUnload sub in the vbscript.
The original Winsock1_DataArrival sub was simply converted to a
function - I have no idea what should actually be done with it.
Can someone give me a clue here?
Thanks.
--------------------------------------------------------
<body onload='ConnectSocket();' onunload='CloseSocket();'>
<object id='Winsock1' classid='clsid:---A_BUNCH_OF_NUMBERS---'
codebase='/mywinsock.dll'></object>
<script type='text/javascript'>
function ConnectSocket(){
Winsock1.CloseConnection;
Winsock1.RemoteHost = Window.Location.Hostname;
Winsock1.RemotePort = 1234;
Winsock1.LocalPort = 0;
Winsock1.Connect;
}
function CloseSocket(){
Winsock1.CloseConnection;
}
function Winsock1_DataArrival(bytesTotal){
var Msg;
Winsock1.Getdata Msg;
Msg = Mid(Msg,2);
alert(Msg);
}
</script>
--------------------------------------------------------
On Wed, 17 Nov 2004 16:31:09 -0700, Martin <ma**********@comcast.net>
wrote:
Shown below is the body of a web page I'm developing. When it loads, a
socket connection is established back to a socket that's on my server.
I can then send a message from the server and it will show up on this
page. This works as intended (IE only, of course).
I'm going to add some functionality to this script and I want to do it
in javascript - I'd like to do this part in javascript also.
Can someone tell me what I need to do to translate this?
Thanks.
<body>
<object id='Winsock1' classid='clsid:---A_BUNCH_OF_NUMBERS---'
codebase='/mywinsock.dll'></object>
<script language=vbscript>
<!--
Sub Window_OnLoad
Winsock1.CloseConnection
Winsock1.RemoteHost = Window.Location.Hostname
Winsock1.RemotePort = 1234
Winsock1.LocalPort = 0
Winsock1.Connect
End Sub
Sub Window_OnUnload
Winsock1.CloseConnection
End Sub
Sub Winsock1_DataArrival(bytesTotal)
Dim Msg
Winsock1.Getdata Msg, vbString
alert(Msg)
End Sub
-->
</script>
</body>