473,396 Members | 1,799 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,396 software developers and data experts.

Test if my page is up using javascript?


I want to supply a button on my public web page if I have opened up my
private web page, but disable it or remove it if the private page is shut
down. Is this possible?

In other words, I often have a port open for a chat page and I use
no-ip.com to do a port redirect. When the port is open, I want my public
page to test the port when a user loads the page, and if the port is
available, supply a button to click over to it.

Sort of like the service at http://www.canyouseeme.org/, except I would
provide the ip and port in the code.

Can this be done with Javascript? Thanks for any help.
Sep 10 '06 #1
4 1387
If both are on the same domain (different subdomains are okay) you
could use a cookie.

If that won't work, your other option (as I see it) is more convoluted.
Have the private page set up a script that polls the server (either
one) every few seconds, with something tagging along on the request to
ID whoever is on the page. You will need something server side to keep
track of the polling, but the JS would be easy: just request a PHP (or
asp, etc) generated image with new Image().src='polling.php'. Set up
something similar on the public page that does likewise, but requests a
differant image. Then if your polling shows that the person IS on your
private page, return a single pixel gif, but return your button
otherwise.

Bill DeWitt wrote:
I want to supply a button on my public web page if I have opened up my
private web page, but disable it or remove it if the private page is shut
down. Is this possible?

In other words, I often have a port open for a chat page and I use
no-ip.com to do a port redirect. When the port is open, I want my public
page to test the port when a user loads the page, and if the port is
available, supply a button to click over to it.

Sort of like the service at http://www.canyouseeme.org/, except I would
provide the ip and port in the code.

Can this be done with Javascript? Thanks for any help.
Sep 11 '06 #2
Hi, Joshie. Thanks for taking the time to respond.

Of course, I don't know or else I wouldn't ask, but that seems a little
complicated. Perhaps I asked the question wrong. I had envisioned something
like...

" if (ping(address)) then hotbutton else greybutton "

....but, of course, in javascript.

I don't think I need constant updating, just a check on loading the page.
"Joshie Surber" <jo**********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
If both are on the same domain (different subdomains are okay) you
could use a cookie.

If that won't work, your other option (as I see it) is more convoluted.
Have the private page set up a script that polls the server (either
one) every few seconds, with something tagging along on the request to
ID whoever is on the page. You will need something server side to keep
track of the polling, but the JS would be easy: just request a PHP (or
asp, etc) generated image with new Image().src='polling.php'. Set up
something similar on the public page that does likewise, but requests a
differant image. Then if your polling shows that the person IS on your
private page, return a single pixel gif, but return your button
otherwise.

Bill DeWitt wrote:
I want to supply a button on my public web page if I have opened up my
private web page, but disable it or remove it if the private page is
shut
down. Is this possible?

In other words, I often have a port open for a chat page and I use
no-ip.com to do a port redirect. When the port is open, I want my public
page to test the port when a user loads the page, and if the port is
available, supply a button to click over to it.

Sort of like the service at http://www.canyouseeme.org/, except I
would
provide the ip and port in the code.

Can this be done with Javascript? Thanks for any help.

Sep 11 '06 #3

Bill DeWitt wrote:
Hi, Joshie. Thanks for taking the time to respond.

Of course, I don't know or else I wouldn't ask, but that seems a little
complicated. Perhaps I asked the question wrong. I had envisioned something
like...

" if (ping(address)) then hotbutton else greybutton "
Why not have your "sometimes offline" site provide the image for the
button. If your site's not there, then no picture...leaves you with
other things to think about...

or...

Another option is to fire off an XmlHttpRequest to the "sometimes
offline" site and read the status. If you don't get a 200 (or if you do
get a 404 it's up to you) then no show, otherwise, do show...

HTH
>
...but, of course, in javascript.

I don't think I need constant updating, just a check on loading the page.
"Joshie Surber" <jo**********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
If both are on the same domain (different subdomains are okay) you
could use a cookie.

If that won't work, your other option (as I see it) is more convoluted.
Have the private page set up a script that polls the server (either
one) every few seconds, with something tagging along on the request to
ID whoever is on the page. You will need something server side to keep
track of the polling, but the JS would be easy: just request a PHP (or
asp, etc) generated image with new Image().src='polling.php'. Set up
something similar on the public page that does likewise, but requests a
differant image. Then if your polling shows that the person IS on your
private page, return a single pixel gif, but return your button
otherwise.

Bill DeWitt wrote:
I want to supply a button on my public web page if I have opened up my
private web page, but disable it or remove it if the private page is
shut
down. Is this possible?
>
In other words, I often have a port open for a chat page and I use
no-ip.com to do a port redirect. When the port is open, I want my public
page to test the port when a user loads the page, and if the port is
available, supply a button to click over to it.
>
Sort of like the service at http://www.canyouseeme.org/, except I
would
provide the ip and port in the code.
>
Can this be done with Javascript? Thanks for any help.
Sep 11 '06 #4

"Tom Cole" <tc****@gmail.comwrote :
>
Why not have your "sometimes offline" site provide the image for the
button. If your site's not there, then no picture...leaves you with
other things to think about...
Hmm... I will try this, but I suspect that my "integrated chat/server
software will not allow it.
Another option is to fire off an XmlHttpRequest to the "sometimes
offline" site and read the status. If you don't get a 200 (or if you do
get a 404 it's up to you) then no show, otherwise, do show...
This sounds possible, both that it could work and that I could
accomplish it 8-) Although I have no idea what a "XmlHttpRequest " is...

I will go look it up now, thanks for your response!
Sep 11 '06 #5

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

Similar topics

25
by: Treetop | last post by:
I have seen some codes that can test for the browser and give values accordingly. I tried to read the FAQ, but was unable to find a simple version of this. What I want is If Netscape-test {...
1
by: stegada | last post by:
Hi, i must determine if client's browsers support ActiveX controls. Is it possible to obtain this information using Javascript? Thank's a lot. Stefano
7
by: joey.powell | last post by:
I have a home page with username and password textboxes and a login button for purposes of users being able to log in (forms authentication) directly on the site home page. I also have a dedicated...
133
by: Alan Silver | last post by:
Hello, Just wondered what range of browsers, versions and OSs people are using to test pages. Also, since I don't have access to a Mac, will I have problems not being able to test on any Mac...
3
by: lofty00 | last post by:
hello, sorry about the repost - I've been posting to several groups and I've decided it's better to make a single repost to all of them rather than an extra post in each. I've been trying to...
17
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
60
by: marss | last post by:
Maybe anyone know good free online JavaScript knowledge test? This not exactly a system for testing online required - it may be simply list of questions with variants of answers (I have to prepare...
4
by: Matt | last post by:
Hello all, I have just discovered (the long way) that using a RegExp object with the 'global' flag set produces inconsistent results when its test() method is executed. I realize that 'global'...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.