HTML Event Handlers

Ratings:
(4)
Views:1058
Banner-Img
  • Share this blog:

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 every time 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>

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox