Test if my page is up using javascript?

Discussion in 'Javascript' started by Bill DeWitt, Sep 11, 2006.

  1. Bill DeWitt

    Bill DeWitt Guest

    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.
    Bill DeWitt, Sep 11, 2006
    #1
    1. Advertising

  2. 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.
    Joshie Surber, Sep 11, 2006
    #2
    1. Advertising

  3. Bill DeWitt

    Bill DeWitt Guest

    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" <> wrote in message
    news:...
    > 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.

    >
    Bill DeWitt, Sep 11, 2006
    #3
  4. Bill DeWitt

    Tom Cole Guest

    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" <> wrote in message
    > news:...
    > > 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.

    > >
    Tom Cole, Sep 11, 2006
    #4
  5. Bill DeWitt

    Bill DeWitt Guest

    "Tom Cole" <> wrote :
    >
    > 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 :cool: Although I have no idea what a "XmlHttpRequest " is...

    I will go look it up now, thanks for your response!
    Bill DeWitt, Sep 12, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sting
    Replies:
    5
    Views:
    1,610
    Natty Gur
    Jun 8, 2004
  2. Replies:
    8
    Views:
    16,068
    catherine sea
    Oct 26, 2010
  3. Robert Allan Schwartz
    Replies:
    7
    Views:
    364
    Marco Manfredini
    Aug 13, 2004
  4. Skybuck Flying

    Call oddities: &Test() vs &Test vs Test

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    683
    Skybuck Flying
    Oct 4, 2009
  5. Joel Ross
    Replies:
    0
    Views:
    219
    Joel Ross
    Sep 4, 2003
Loading...

Share This Page