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

Chapter 25. Advanced Microsoft Dynamic H... > Position HTML Elements with Dynamic ...

Position HTML Elements with Dynamic HTML

One exciting possibility with Dynamic HTML is the capability to reposition HTML elements on the Web page. To do this, change the left and top properties of the element's style object (which, in turn, is a property of the element). This change can be done either automatically or in response to user interaction.

Listing 25.6 shows an example of a Dynamic HTML document that enables the user to position an HTML element—in this case a group of pictures—on the Web page. In this example, a table containing three images is contained within a <span> element. An onclick event is attached to the <span>, which is used to toggle whether it can be moved and to initialize the coordinates for the move. An onmousemove event is attached to the document itself; when the <span> region has moving enabled, the position of the mouse determines where the region is moved. Figure 25.9 shows the Web page immediately after it is loaded, and Figure 25.10 shows it while it is being moved. Note that the movement status and the current x,y coordinate, as well as the value of some of the internal variables used by the script, are shown in the text boxes near the bottom of the page.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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