Books
in black and white
Main menu
Home About us Share a book
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

Javascript for dummies 4th edition - Veer E.V

Veer E.V Javascript for dummies 4th edition - Wiley publishing , 2004. - 387 p.
ISBN: 0-7645-7659-3
Download (direct link): javascriptfordummies2005.pdf
Previous << 1 .. 57 58 59 60 61 62 < 63 > 64 65 66 67 68 69 .. 118 >> Next

One image, multiple event handlers
Rolling your mouse pointer over the different parts of this image causes different messages to display at the bottom of the window (in a property of the window called the status bar).
Writio
«
Publish - Promote - Sell
PROMOTE your wribng
^ Attaching m...
j My Compute»
I DOS Prompt 9:09 PM
£] Attaching multiple event handlers to a single image (from JavaScript For Dummies, 4th edition) • Microsoft Inter...
File Edit View Favorites Tools Help
e 0-a-usato
v a go
Back ’ О i*l i»l tii iz F
Address C:\em\write\)sfd4e\scrpts\llst08O6.htm
One image, multiple event handlers
Rolling your mouse pointer over the different parts of this image causes different messages to display at the bottom of the window (in a property of the window called the status bar).
Figure 8-12:
A standard message appears on the status bar when the user mouses anywhere on the image.
Writio

Publish - Promote - Sell
£) Wnting for the Web
Attaching m...
' TextPad - [... I СЭ C:\Docume..
j My Computer
I DOS Prompt 9:10 PM
Chapter 8: Creating Interactive Images 179
*v*co
Listing 8-6 (list0806.htm) shows you how to create a customized message to display on the status bar when a user mouses over a specific area of an image.
Listing 8-6: Designating Image Hotspots
<HTML>
<HEAD>
<TITLE>Attaching multiple event handlers to a single image (from JavaScript For Dummies, 4th Edition)</TITLE>
</HEAD>
<BODY BGCOLOR="black" TEXT="white">
<H1>One image, multiple event handlers</H1>
Rolling your mouse pointer over the different parts of this image causes
different messages to display at the bottom of the window (in a property of the window called the <B>status</B> bar).
<P>
<HR>
<P>
<CENTER>
<!--
The HTML areas "carve" up a single image. Defining separate event handlers for each area lets you display a different message in the window's status bar depending on where a user's mouse moves or clicks.
-- >
<IMG height=208 src="splash.jpg" width=241 useMap=#newsplash border=0>
<MAP name=newsplash>
<AREA
onMouseOver="window.status='Writing for the Web'; return true" onMouseOut="window.status=''; return true" shape=POLY target=_top
coords=1,2,1,46,78,48,80,197,240,201,239,18,93,12,94,2
>
<AREA
onMouseOver="window.status='SELL your writing'; return true" onMouseOut="window.status=''; return true" shape=RECT target=_top coords=216,0,241,16
>
<AREA
onMouseover="window.status='PROMOTE your writing'; return true" onMouseout="window.status=''; return true" shape=RECT target=_top coords=149,0,209,15
>
<AREA
onMouseOver="window.status='PUBLISH your writing'; return true"
(continued)
180 Part III: Making Your Site Easy for Visitors to Navigate and Use
Listing 8-6 (continued)
onMouseOut=”window.status='' ; return true” shape=RECT target=_top
coords=94,0,140,14
>
</MAP>
</CENTER>
</BODY>
</HTML>
HTML areas are the constructs that let you carve an image into separate pieces. The image itself stays where it is, and the areas that you define just let you define arbitrary ways of interacting with that image.
You can define as many areas for an image as you want, sized and shaped however you like (courtesy of the coords attribute). You define an area by using the HTML <AREA> and <MAP> tags, as shown in Listing 8-6. Each area gets to define its own event handlers.
Four separate areas are defined in Listing 8-6:
The portion of the image that says Publish. The onMouseOver event handler associated with this area displays the message PUBLISH your writing.
The portion of the image that says Promote. The onMouseOver event handler associated with this area displays the message PROMOTE your writing.
The portion of the image that says Sell. The onMouseOver event handler associated with this area displays the message SELL your writing.
The rest of the image not described by the preceding areas. The onMouseOver event handler associated with this leftover area displays the generic message Writing for the Web.
To add a link to a hotspot, all you need to do is define a value for the HREF attribute of the <AREA> tag, as the following code shows:
<AREA
onMouseover=”window.status='PROMOTE your writing'; return true” onMouseout=”window.status=''; return true” shape=RECT target=_top coords=149,0,209,15 href=”http://www.somePromotionPage.com”
>
To create distinct areas within an image, you need to know the x,y coordinates that describe that area. Most graphic-manipulation tools on the market today, including Macromedia Fireworks and Adobe ImageReady, allow you to import a picture, outline which areas you want to create, and then — boom! — they generate the necessary coordinates for you.
Chapter S
Creating Menus
In This Chapter
^ Using DHTML to create pull-down menus ^ Creating dynamic sliding menus ^ Taking advantage of third-party DHTML menu tools
rn «ynamic HTML, or DHTML, refers to the collection of client-side languages and standards that you use to create Web pages that change appearance dynamically after they’re loaded into a user’s Web browser.
Previous << 1 .. 57 58 59 60 61 62 < 63 > 64 65 66 67 68 69 .. 118 >> Next