Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2008
    Location
    North Wales
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How do I Ping in JavaScript?

    Hi

    I'm new to JavaScript and am still trying to grasp the basics. However, I need to create something which could be quite complex and am beginning to wonder if JavaScript may not be the right language to use for the task.

    At work, I find myself pinging all the time - in fact it is quite often the case that I'll have in excess of 30 pings running to different terminals worldwide simultaneously. To make life easier, I'd like to create a script where I can run nermerous pings side by side (rather then opening a new command prompt for each ping!) I'd also like to have some notification once the connection is live, maybe a system bleep for example to grab my attention, and also a display of how long the connection has been alive for (so I can determine whether or not it's worth connecting to the terminal or if it's still booting up!)

    Anyway pointers would be gratefully appreciated.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,733
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Sorry, no... JS isn't capable of anything like this unless the host
    (usually a browser, but not necessarily) provides some interface to do
    it.

    It is possible to ping a specific image:-

    See:-

    http://www.webmasterworld.com/forum91/2420.htm

    http://www.chronosight.net/view/2007...t-to-ping.html
    Last edited by Philip M; 07-21-2008 at 08:00 AM.

  • Users who have thanked Philip M for this post:

    morgansolutions (07-22-2008)

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,189
    Thanks
    10
    Thanked 569 Times in 550 Posts
    you can only make connections to a server on your own domain.

    you can use a synchronous HEAD request to contact your server with just one packet coming back, essentially a beefy ping, and able to be timed as well.

    and like philip m said, if you can find an image on the remote server, you can cross domains and verify status by checking the height of the image once it loads.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •