JavaScript DHTML/Development/JavaScript in HTML

Материал из Web эксперт
Перейти к: навигация, поиск

A Basic JavaScript Starter Document

   <source lang="html4strict">

<html> <head>

 <title>My first HTML page</title>
 <script type="text/javascript">
 
 </script>

</head> <body>

</body> </html>


      </source>
   
  


Embedding a JavaScript Function

   <source lang="html4strict">

<html> <head>

 <title>JavaScript Unleashed</title>
 <script type="text/javascript">
 
 </script>

</head> <body>

 <script type="text/javascript">
 
 </script>

</body> </html>


      </source>
   
  


Embedding JavaScript in HTML

   <source lang="html4strict">

<html> <head> <title>Hello World!</title> </head> <body> <script language="JavaScript"> document.write("Hello World!"); </script> </body> </html>

      </source>
   
  


HTML comment that hides the script.

   <source lang="html4strict">

/* Examples From JavaScript: The Definitive Guide, Fourth Edition Legal matters: these files were created by David Flanagan, and are Copyright (c) 2001 by David Flanagan. You may use, study, modify, and distribute them for any purpose. Please note that these examples are provided "as-is" and come with no warranty of any kind. David Flanagan

  • /

<script language="JavaScript">

</script>


      </source>
   
  


Inserting Source JavaScript Files

   <source lang="html4strict">

<html> <head> <title>Using the SRC attribute of the script tag.</title> </head> <body> <script language="JavaScript" SRC="src.js"> </script> </body> </html>

//File:src.js alert("Hi");

      </source>
   
  


JavaScript Embedded in an HTML File

   <source lang="html4strict">

<html> <head>

   <title>Status Bar</title>
   <script type="text/javascript">
   
   </script>

</head>

<body>

 

 

http://www.samspublishing.ru

<a href="http://www.samspublishing.ru" onmouseover="changeStatus();return true">Go...</a>

To change the default status bar message, select a message from the list below and click the Change button.

 <form name="statusForm" method="POST">
   <select name="messageList" size="1">
     <option selected>Welcome to the large URL page.</option>
     <option>On route to Sams Publishing</option>
     <option>This page intentionally left (nearly) blank.</option>
     <option>An exciting example of changing status bar text.</option>
   </select>    <input type="button" name="Change" value="Change"
      onclick="changeDefaultStatus()">
 </form>

</body> </html>


      </source>
   
  


JavaScript Template File

   <source lang="html4strict">

<html> <head>

 <meta http-equiv="Content-Script-Type" content="text/javascript">
 <title>My First JavaScript Script</title>
 <script language="JavaScript">
 
 </script>

</head> <body>


</body> </html>


      </source>
   
  


Using HTML Comments to Hide JavaScript Code

   <source lang="html4strict">

<html> <head> <title>Using HTML comments to hide JavaScript code</title> </head> <body> <script language="JavaScript">

</script> </body> </html>

      </source>
   
  


Using the Head for Definitions

   <source lang="html4strict">

<HTML> <HEAD> <TITLE>Using the HEAD for definitions</TITLE> <SCRIPT language="JavaScript">

</SCRIPT> </HEAD> <BODY> <SCRIPT language="JavaScript">

</SCRIPT> </BODY> </HTML>

      </source>