473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Translate from vbscript to javascript?


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>

Jul 23 '05 #1
1 1928
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>


Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John Davis | last post by:
When I create new documents in Dreamweaver, there are several choices for ASP creation: ASP JavaScript: run at client side?? ASP VBScript: run at server side?? ASP.NET C# ASP.NET VB I don't...
29
by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
20
by: Harag | last post by:
Hi All. I'm stating out doing some web developing. I was wondering which of the server side languages should I concentrate on and learn. I Know CSS, HTML, T-SQL I can look at the client...
5
by: gpence | last post by:
!!! Newbie question warning !!! I am somewhat familiar with javascript's ability to "access" the browser's favorites list -- for example, using window.home() will take you to the default URL --...
1
by: Ian Sedwell | last post by:
Hi guys Many thanks to all who replied to my original question. Actually, it's dead easy and the way I was doing it was correct the first time. You do indeed simply call the VBScript routine...
2
by: duncan | last post by:
why does this work :- <HEAD> ...... <SCRIPT LANGUAGE="javascript"> function test() { alert("test 1") } </SCRIPT>
10
by: Shadow Lynx | last post by:
That subject packs a whallop, so let me explain in better detail what's happening and how it relates to ASPX pages... In a nutshell, if the first <script /on a page is of type "text/vbscript",...
6
by: rishabhshrivastava | last post by:
Hello All, I am using ASP.NET 2.0 and I am experiencing a problem using vbscript that is this script on client side is preventing the postback of my controls. I have a dropdownlist which is...
2
by: Beemer Biker | last post by:
I put together a few lines of vbscript so I could dump the contents of a string to my C drive. It worked fine in a small test.htm where I put the vbscript at the top of the file. It failed to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.