Web Design

(Nancy Kaufman) #1

217


CHAPTER

Adding Interactivity and Multimedia 9


TIP


What does javascript:void; do in the href attribute?
In order to have a valid anchor tag, you need an href attribute. However, in this example you do not want
the user to leave the page when they click the link, but instead merely to trigger the script. The
javascript:void code essentially tells the browser to ignore the href attribute when the user clicks the
link. Many tutorials suggest adding a pound sign (#) instead, but some browsers reload the page when you
click that link, so javascript:void is safer.

● When viewed in a browser,
the content is visible. When
you click the “hide” link, the
content disappears. When
you click the “show” link,
the content reappears.

q In the body, type <a
href=”javascript:
void”.


w Type onclick=
”showDiv()”>.


e Type descriptive text for the
link.


r Type .


21 24


22 23

Free download pdf