Google Answers Logo
View Question
Q: VbScript in HTML Page ( Answered,   0 Comments )
Subject: VbScript in HTML Page
Category: Computers > Programming
Asked by: vicky2k-ga
List Price: $55.00
Posted: 07 Mar 2004 08:01 PST
Expires: 06 Apr 2004 09:01 PDT
Question ID: 314236
I need to create a Vbscript with a HTML page, vbscript I need should
work like when ever anybody loads the page (say index.html) from
webserver it sends a request to my computer using STATIC IP Address
(XX.XX.XX.XX.)and Port(8888). On the other end my software is
listening for connections on port(8888).

Request for Question Clarification by majortom-ga on 08 Mar 2004 06:14 PST
Hello, vicky2k-ga,

VBscript is not available in web browsers, except some versions of
Internet Explorer; this would not work for many users. VBscript could
be used in an Active Server Page (ASP), but you specified HTML, and of
course ASP by definition runs on the server, *before* the page goes to
the user, so if it is your goal to receive a connection directly from
the user's PC this would not work.

Also, what do you need the connection to actually do once it connects?
Do you care what the content of the request is, or is your goal simply
to learn the address of the user's PC? If I can help you achieve that
in a way that works for all browsers, do you need it to be VBScript,
or would any such solution be acceptable? Javascript is the most
likely candidate for the situation you describe. If you are flexible
about what your software has to do in response, we might not even need
Javascript *or* VBScript.

Thank you!

Clarification of Question by vicky2k-ga on 08 Mar 2004 13:33 PST
Thanks for your response.
Well I create a program in VB.Net name is "Online Website user track",
the program i made is simply can listen on any port (e.g 45450) and
has listbox in which remote IPs (visitors) will be listed. Now what
exaclty the problem is i need a script whether in
JScript/Javascript/VBScript or any other ASP/PHP it should work
whenever my visitor open the page (e.g index.html or index.asp) and it
simply sends me response on the listening port 45450 so that my
program can list the IPs who are connecting to my Website...
I hope you will understand my exact question.

Please respond if you need more clarification.
Subject: Re: VbScript in HTML Page
Answered By: majortom-ga on 08 Mar 2004 17:02 PST
Hello again, vicky2k-ga,

There are two ways to do what you ask. The first is the simplest by
far; but there's a chance that it will slightly undercount visitors
because of possible caching. The second expands slightly on the first
and won't have a caching problem.

METHOD ONE: simply embed this tag in your page:

<img src="http://address.of.your.server:45450/dummy.gif">

This will cause the client's browser to connect to your server on port
45450, in order to request an image file.

Now, to prevent a "broken image" icon from appearing afterwards, your
program just needs to respond with a valid HTTP response header and a
valid image file -- which should be a 1x1 completely transparent GIF
image, just a few bytes in all. Very easy to do.

The header you output must look like this:

HTTP/1.0 200 OK
Content-type: image/gif

Followed by TWO newlines, then the contents of the GIF image file.

You can pick up the completely transparent GIF image file you need here:

Pixel Ruler and Spacer - Useful Tools for Web Design

METHOD TWO: the same as method one, except that you use Javascript to
ensure that the URL in the img tag is always unique, and therefore
never found in the browser's cache, AOL's cache, or any other
interfering cache that might prevent the connection from happening.
Use the following HTML:

var date = new Date();
document.write("<img width=1 height=1
var date = new Date();
<img src="http://address.of.your.server:45450/dummy.gif">

Just as with method one, your server on port 45450 must respond with a
simple but correct HTTP response and a tiny image file, as explained

If the browser has Javascript enabled, then Javascript is used to add
the current time in seconds to the URL, preventing caching from taking
place. If Javascript is disabled, the tag between <noscript> and
</noscript> is still used, ensuring that the best possible count is
obtained under any set of circumstances.

I enjoyed answering this question for you. Please feel free to ask
clarifying questions if anything is unclear. Thank you!

Request for Answer Clarification by vicky2k-ga on 09 Mar 2004 12:59 PST
Is it necessery to use GIF file or any other request from SERVER listening...45450
For your understanding... I am explaining clearly again.
Well the program i made has simple interface which has one textbox
showing my current local ip and port on which it listens for incoming
connections, also has one listbox in which i want to show the visitors
IP addresses remotely.
Only i need is simple BLANK request from client to my server program
to let know my program that visitor has entered the site, so it will
add IPs to my listbox.

The script u suggest is requiring me to program further for sending
that GIF file from my computer to the client browser. But I dont have
setup my program to transfer any file from my comp. to client.
So its going to be difficult for me to make additional features.


Clarification of Answer by majortom-ga on 09 Mar 2004 15:46 PST
Hello again, vicky2k-ga,

I have a solution to that problem for you. However, it is worth
mentioning that the VB.NET code to send that image would not be
complex. A 1x1 transparent GIF
is usually only about 48 bytes. This is something you can easily put in an
array of bytes right in the code if you don't want to access a file.

But if you're sure you don't want to do that, you can solve the problem this way:

var date = new Date();
var image = new Image();
image.src = "http://address.of.your.server:45450/dummy.gif?" + date.getTime();

This will work regardless of whether an actual valid image comes back
from your application or not, and no "broken image" icon will appear.
It works because the image is being "preloaded" but not actually
placed in the page, so the fact that the loading ultimately fails
doesn't interfere with the appearance of the page.

This doesn't work if Javascript is turned off in the browser, but most
users do have it turned on, and your original question did call for a
scripting solution, so this should be sufficient for your needs. If
you decide you really want to also count the users who have Javascript
turned off, you can always look into sending a valid HTTP response
with an image, as described in my original answer.

Thanks for the opportunity to solve this interesting problem.
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy