tailieunhanh - Học JavaScript qua ví dụ part 51

Xử lý một sự kiện vào cửa sổ hoặc Frame Một cửa sổ là trang web chính, trừ khi nó được chia ra thành các khung. Có một số sự kiện đó sẽ ảnh hưởng đến các cửa sổ và khung hình, chúng được mô tả trong Bảng . Các ví dụ sau đây minh họa một số sự kiện có ảnh hưởng đến các cửa sổ và khung. | Handling a Window or Frame Event 465 EXPLANATION continued been called here such as a href onClick validateForm this and the sub-mit method used within the function if the form is OK. See the section Form Validation with Regular Expressions on page 765 in Chapter 17. 7 A deactivated link is assigned an onClick event handler. When the user clicks the link the JavaScript code is executed. The pseudo JavaScript protocol is followed by a reference to the form and a reset method which clears the form fields. See Figure . Figure The focus is in the first box and the field is selected highlighted . Handling a Window or Frame Event A window is the main Web page unless it is divided up into frames. There are a number of events that will affect windows and frames these are described in Table . The following examples illustrate some of the events that affect windows and frames. Table Window and Frame Events Event Handler When It Is Triggered onBlur When the mouse moves away from the window or frame and it loses focus. onFocus When the mouse is clicked or moved in a window or frame and it gets focus. onLoad When a document or image has finished loading. onMove When a window is moved. onUnLoad When a page is exited or reset. The onLoad and onUnLoad Events The onLoad event handler is invoked on the occurrence of a Load event that is when a document its frameset or images have completely finished loading. This includes the point at which all functions have been defined and scripts have been executed and all From the Library of 466 Chapter 13 Handling Events forms are available. This event can be helpful in synchronizing the loading of a set of frames particularly when there might be large images that need to be loaded or all of the frame data hasn t arrived from the server. The onUnLoad event handler is invoked when the page is exited or reset. EXAMPLE html head title load and unload Events title 1 script type text javascript 2

TỪ KHÓA LIÊN QUAN