HTML Script

45 views

A script is a small, embedded program that can add interactivity to your website. For example, a script could generate a pop-up alert box message, or provide a dropdown menu.

Because HTML doesn’t actually have scripting capability, you need to use the <script> tag to generate a script, using a scripting language.

The <script> tags tell the browser to expect a script in between them. You specify the language using the type attribute. The most popular scripting language on the web is JavaScript.

In either case, a generally accepted convention is to place your scripts between the <head></head> tags.

<script type=”text/javascript”>
alert(”I am a script. I ran first!”)
</script>

Athough most (if not all) browsers these days support scripts, some older browsers don’t. If a browser doesn’t support JavaScript, instead of running your script, it would display the code to the user. To prevent this from happening, you can simply place HTML comments around the script. Older browsers will ignore the script, while newer browsers will run it.

<script type=”text/javascript”>
   <– Hide from older browsers
    alert(”I am a script. I ran first!.”)
    Unhide –>
</script>
 



« HTML Url HTML Webserver »
Posted on Wednesday, June 25th, 2008 at 2:18 pm under HTML For Advanced | RSS 2.0 Feed

Post Comment

You must be logged in to post a comment.



ComputerEducationWorld.com All Rights Reserved © RSS | CBSE | Education Boards Of India | What is My IP?