HTML: Script Tag
|
---|
HOME] | Consulting | Design | Maintenance | Project | Testing | Training | Turnkey | Java | C++ | SQL | HTML | JavaScript ] |
© 2002 - 2010 All Rights Reserved Total Application Works
Tell a friend about this site (copy and paste the following HTML page into a file (e.g., using Notepad).) |
---|
<html> <head> <title>Example of a link </title> </head> <body> <a href="http://sumtotalz.com/TotalAppsWorks/HTML/Script.html"> Script Tag </a> This is a link to a 2006 Corolla for sale2006 Corolla for sale - 13,490 miles"</body> </html> |
The purpose of this tutorial is to show you how to write a HTML page, using scripts. What is HTML (HyperText Markup Language)? HTML is a layout/tag language that is used to organize text and/or images on a web page. Scripts offer authors a means to extend HTML documents in highly dynamic ways. For example, scripts may:
The <script> tag is used to define a client-side script, such as a JavaScript. A client-side script is a program that may accompany an HTML document or be embedded directly in it. The program executes on the client's machine when the document loads, or at some other time such as when a link is activated. HTML's support for scripts is independent of the scripting language. The script element either contains scripting statements or it points to an external script file through the src attribute. The required type attribute specifies the MIME type of the script. Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content. See Figure 1 for an example.
<html> <body> <script type="text/javascript"> document.write("Hello World!<br><br>from <br><br>") document.write("Ronald Holland <br><br>@ <br><br>Total Application Works") </script> </body> </html> |
|
Figure 1: Example of a Hello world script |
---|
An example of a more robust web page, with a client side script, looks like:
<html> <head> <title> This an example of a more robust web page </title> <script type="text/javascript"> function sendMsg() { alert("Page is loaded\n\nFrom\n\nRonald Holland\n\n@\n\nTotal Applications Works"); } </script> </head> <body> </body onload="sendMsg()"> <h1>Hello World!</h1> </html> |
Hello World! |
Figure 2: HTML Example of a more robust web page |
---|
An example of a more robust web page, with a client side script, looks like:
<html> <head> <title>Car for sale</title> </head> <body> <form> <input type=button onClick="location.href='http://www.cargurus.com/Cars/inventorylisting/viewDetailsFilterViewInventoryListing.action?sourceContext=carGurusHomePage_false_0&newSearchFromOverviewPage=true&embedType=NONE&entitySelectingHelper.selectedEntity=c3950&entitySelectingHelper.selectedEntity2=c3950&ign-makerId-entitySelectingHelper.selectedEntity=m7&ign-modelId-entitySelectingHelper.selectedEntity=d295&ign-carId-entitySelectingHelper.selectedEntity=c3950&ign-car2Id-entitySelectingHelper.selectedEntity=c3950&zip=27511&distance=MILES_75#listing=29588803'" value='Car for sale'> </form> </body> </html> |
|
Figure 3: How to use a Button |
---|
Attribute | Value | Description |
---|---|---|
type | MIME-type | Specifies the MIME type of a script |
Attribute | Value | Description |
---|---|---|
charset | charset | Specifies the character encoding used in an external script file |
defer | defer | Specifies that the execution of a script should be deferred (delayed) until after the page has been loaded |
src | URL | Specifies the URL of an external script file |
xml:space | preserve | Specifies whether whitespace in code should be preserved |
The <script> tag does not support any standard attributes.
The <script> tag does not support any event attributes.
HOME]
Consulting
Design
Maintenance
Project
Testing
Training
Turnkey
Java
C++
SQL
HTML
JavaScript ]
© 2002 - 2008 All Rights Reserved Total Application Works