• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 17. Scripts > Creating a Button that Executes a Script

Creating a Button that Executes a Script

HTML 4 offers a new kind of button, not restricted to a FORM element (see page 193) that you can add to your Web page. You can associate the button with a script to give your visitor full control over when the script should be executed.

To create a button that executes a script:

1.
Type < BUTTON TYPE="button".

2.
Type NAME="name", where name is the identifier for the button.

Figure 17.10. Notice that the script is the same as the one used in the example in Figure 17.7. The style information here is optional, but it does make the button stand out. I also could have added an image.


3.
Type ONCLICK="script", where script is the code (usually JavaScript) that will run when the visitor clicks the button.

4.
If desired, type STYLE="font: 14pt Lithos Regular; background:red" (or whatever) to change the appearance of the text on the button.

Figure 17.11. Although the BUTTON tag is a standard part of HTML 4, only Explorer for Windows currently supports it (with or without scripts).


5.
Type >.

6.
If desired, type the text that should appear on the button.

Figure 17.12. A click on the button executes the script, as shown here.


7.
Type </BUTTON>.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint