By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,599 Members | 1,872 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,599 IT Pros & Developers. It's quick & easy.

Test if my page is up using javascript?

P: n/a

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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a

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

P: n/a

"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 discussion thread is closed

Replies have been disabled for this discussion.