1 / 7

Using External JavaScript Documents

Using External JavaScript Documents. Instructor: Joseph DiVerdi, Ph.D., MBA. Several Places To Keep Scripts. Reference Internal Script. <!DOCTYPE HTML PUBLIC ... > <HTML> <HEAD> <TITLE>Today's Date</TITLE> <SCRIPT TYPE="text/javascript"> function print_date() {

lorant
Download Presentation

Using External JavaScript Documents

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using External JavaScript Documents Instructor: Joseph DiVerdi, Ph.D., MBA

  2. Several Places To Keep Scripts

  3. Reference Internal Script <!DOCTYPE HTML PUBLIC ... > <HTML> <HEAD> <TITLE>Today's Date</TITLE> <SCRIPT TYPE="text/javascript"> function print_date() { var my_date = new Date(); document.write(my_date.toLocaleString()); } </SCRIPT> </HEAD> <BODY> The current date and time are: <SCRIPT TYPE="text/javascript">print_date();</SCRIPT> </BODY> </HTML>

  4. Reference External Script <!DOCTYPE HTML PUBLIC ... > <HTML> <HEAD> <TITLE>Today's Date</TITLE> <SCRIPT TYPE="text/javascript" SRC="/~diverdi/my_script.js"> </SCRIPT> </HEAD> <BODY> The current date and time are: <SCRIPT TYPE="text/javascript"> print_date(); </SCRIPT> </BODY> </HTML>

  5. Common JS Directory

  6. Display Current Time & Date • Requires Function Definition • Uses External JavaScript Document • Create javascript Directory in html Directory • Create file my_script.js in javascript • Include Function in my_script.js

  7. Contents of my_script.js // simple function definition function print_date() { var my_date = new Date(); document.write(my_date.toLocaleString()); } • Note That This File Contains No HTML

More Related