11.6 Event Handlers
Whew! We finally finished examining the Point
class definition. In this section, we move on to the Point Tracker web page’s event-handler functions. The Point Tracker web page’s html
element has an onclick
attribute that calls the captureClick
event-handler function when the user clicks anywhere on the web page. Here’s the html
element’s start tag with the onclick
attribute:
<html lang="en" onclick="captureClick(event);">
Originally, we added the onclick
attribute to the web page’s body
element instead of to the html
element. That works OK, but not great. We want mouse clicks to be captured anywhere on the web page’s viewport. The viewport is the area below the browser window’s address bar and within the browser window’s ...
Get Web Programming with HTML5, CSS, and JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.