• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

HTML Event Handlers

Writing Event Handler

It is very easy to write an even handler. Following example explains how to write an event handler. Let’s write one simple function myalert in the header of the document. We will call this function when any user will bring mouse over a paragraph written in the example :

<head>

<title> Event Handler Example t</title>

<script type=”text/javascript”>

function myalert()

{

alert(“I am an event handler……”);

return;

}

</script>

</head>

<body>

<span onmouseover-“myAlert();”>

Bring your mouse here to see an alert

</span>

</body>

Now this will produce following result. Bring your mouse over this line and see the result :

Bring your mouse here to see an alert

The <noscript > Element

You can also provide alternative info for users whose browsers don’t support scripts and for users who have disabled scripts. You do this using the <noscript> tag.

<noscript>

Please enable javascript

</noscript>

 

Default Scripting Language

You can specify a default scripting language for all your scripting tags to use. This saves you from having to specify the language everytime you use a script tag within the page. Below is the example :

<meta http-equiv=”Content-Script-Type” content=”text/Javascript”>

 

HTML Meta Tag

HTMl lets you specify metadata-information about a document rather than document content-in a variety of ways. The META element can be used to include name/value pairs describing properties of the HTML document, such as author, Expiry Date, a list of key words, author etc.

Metadata provided by using meta tag is a very important part of the web. It can assist search engines in finding the best match when a user performs a search. Search engines will often look at any metadata attached to a page especially keywords- and rank it higher than another page  with less relevant metadata, or with no metadata at all.

 

Adding Meta Tags to your Documents

You can add metadata to your web pages by placing <meta> tags between the <head> and </head>tags. The can include the following attributes

Attribute                                          Description
Name Name for the property, can be anything, Examples include, keywords, description, author, revised, generation etc.
Content Specifies the property’s values
Scheme Specifies a scheme to use to interpret the property’s value(as declared in the content attribute)
http-equiv Used for http response message headers. For example http-equiv can be used to refresh the page or to set a cookie. Value include content-type,expires,refresh and set-cookie

 

Note

Core attributes for all the elements are discussed in next chapter.

Meta Tag Examples

Let’s see few important usage of Meta Tags.

Specifying Keywords

We specify keywords which will be used by the search engine to search a web page. So using following tag you can specify important keywords related to your page.

<head>

<meta name=”keywords” content=”HTML, meta tags, metadata”/>

</head>

Summary
Review Date
Reviewed Item
HTML Event Handlers
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on HTML Event Handlers"

Leave a Message

Your email address will not be published. Required fields are marked *

Site Disclaimer, Copyright © 2016 - All Rights Reserved.