How to Talk to an NTP Server Using JavaScript

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Email

The Network Time Protocol (NTP) is a language used to coordinate time on the Internet. You use JavaScript to call NTP services and synchronise your website's time with official time servers provided by companies, such as Microsoft. Talking to an NTP server using JavaScript is beneficial when you want to get the accurate time and display it on your web pages, and it is also useful to store it when users submit articles or place an order.

Skill level:
Moderate

Other People Are Reading

Instructions

  1. 1

    Right-click the HTML file you want to use to grab the NTP time. Select "Open With." Click "Notepad," and then click "Open." This opens the HTML file into Notepad, the default text editor.

  2. 2

    Activate the NTP object in your HTML file. Add the following line of HTML code between the "<head>" and "</head>" tags:

    <object id="ntpobject" codeBase="http://www.activexperts.com/files/activsocket/asocket.dll" height="50" width="300" classid="CLSID:916C28A2-8314-4AA5-9E25-18E5DEFBE2A3" viewastext></object>

  3. 3

    Create the JavaScript block that calls the NTP server. Add the following code underneath the NTP plugin you entered in step two:

    <script type="text/JavaScript">

    var ntp;

    ntp = new ActiveXObject ( "ActiveXperts.Ntp" );

    </script>

  4. 4

    Click the Notepad "File" menu item, and then click "Save." Double-click the file name on your computer to test the new settings and view the NTP JavaScript code.

Tips and warnings

  • If you have a third-party HTML editing application installed, you can use that software instead of the default text editor.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.