banner
Welcome to HTML.co.uk, the number one resource for all news, information, and happenings regarding HTML.

Updates: HTML.co.uk has just been relaunched. Subscribe to our RSS Feed to stay on top of HTML news and techniques.
Oct
17th

HTML Event Handlers

Author: Editor | Files under HTML Tutorials
Tags for this article: , , , , ,

In generic terms event handlers can be described as those commands which are optional and are required only when a change occurs either with the host or the service. All the interactions between the user and any web page always get tracked by web browser through events. Therefore, even the smallest activity that is initiated by the user is an event; which can include anything from clicking on a button or loading or reloading a web page or placing the mouse on the image or removing the cursor from the image to hyperlink and many more. Event handlers are nothing but a simple solution provided by Java Script for responding to all the user actions. Event Handlers are always accompanied by HTML code and can be triggered either by a user or a browser.

Events can be separated into two major classes, user related events and documents related events. User related events are nothing extraordinary, they are the standard keyboard and the mouse events that occur when a user handles any of the two and are generic in all the HTML elements and can be classified as mouse and the keyboard events. These would mainly include onKeyDown, onKeyPress, onkeyUp, onDblClick, onMouseUp, onMouseDown and onClick attributes. The documents related events are those special events that occur either when the browser is displaying and managing the HTML documents or are mainly related to the handling of different types of states and actions of HTML form controls. These would majorly include onSubmit, onReset, onChange and onSelect attributes.

The event handlers can also be classified based on their dependencies on the computer devices; event handlers which are device dependent, as the name describes are those event handlers directly dependent on the device such as mouse or keyboard and the others are those ones which are device independent, it does not mean that they are not dependent on any device, they definitely are device dependent but not directly rather through some other means.

The device dependent event handlers in 4.01 version of HTML include ondblclick, onMouseover and onMouseout and are mainly used in the situations where only the presentation of any particular element needs to be changed; while the device independent event handlers include onSelect, onBlur and onFocus primarily find their use in those situations when the even handler is supposed to handle or perform much more than just changing the presentation of any particular element. Whenever using the device dependent event handlers, always remember to test them thoroughly in order to ensure that no additional keyboard event would be required later.

Through the related ‘on’ event attributes, HTML is capable of supporting a rich set of event handlers. Either a quoted string which comprises of one or more script statements or the name of a function which may be described elsewhere in the document can be used to depict the value of the event handler.


Sep
17th

Naming and Targeting Frames

Author: Editor | Files under Frames, HTML Tutorials
Tags for this article: , , , , , ,

Frame naming and targeting is used when the developer wants to associate the link of one frame with the output of another frame. For example, suppose there are two vertical frames. The left one consists of all the links and whenever the user clicks any one of them then the HTML document associated with that link is displayed on the right hand side frame without opening up a new window or affecting the contents of the left side frame. That means the left side contents remain static and the content of the right side frame changes.

These types of frames are very useful and are used to make web site navigation user friendly and interactive. One thing to be noted is that frame targeting cannot be done without naming the frame. The name is necessary because it becomes the identity of the frame and is used by the other frames.

How to do naming and targeting?

The naming of the frame is done using the NAME attribute and the targeting is done with the help of TARGET attribute. The frames can be targeted in different styles. It can be done on an A (Anchor) element, on a BASE element, on an AREA element and on a FORM element.

Targeting for Anchor (A) element:

The Anchor tag (A) which is used at the time of defining hyperlinks in the HTML document is also used while targeting the frames. It specifies the linked document which is to be displayed after the user clicks on a particular link in the frame. For example:

<HTML>
<frameset rows=45%,10%,45%>
<frame name=”upper”>
<frame name=”middle” source=”doc1.html”>
<frame name=”bottom”>
</frameset>
</HTML>

Now the following HTML code has to be written for the doc1.html document

<HTML>
<UL>
<LI><A target=”upper” HREF=”http;//www.italics.in”> Italics Home Page </A></LI>
<LI><A target=”lower” HREF=”http://www.contentmantra.com”> Content Mantra Home Page </A></LI>
</UL>
</HTML>

Whenever the user will click on the Italics Home Page then the web page will get displayed in the upper frame and if he clicks on the Content Mantra Home Page then the relevant web site will be displayed in the lower frame.

Targeting for a BASE element

In this the TARGET attribute uses a default window_name and target all the links towards the same window.

<BASE target=”window_name”>

Targeting for the AREA element

The AREA element type is defines by the Internet-Draft of Client-Side image maps. It is used with the image maps and defines a particular area on the client side image map. It associates a link with that area containing all the details and when the TARGET element is used then the output of the link can be directed towards a separate window.

<AREA shape=”shape” COORDS=”x,y,z…..” HREF=”URL” target=”window_name”>

Targeting for the FORM element

Without any defined target window the FORM element displays the output of the form submission in the same window used to submit the form. The TARGET attribute can be used to direct this output to another window.

<FORM Action=”URL” target=”window_name”>