Tham khảo sách 'javascript bible_ chapter 17', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Link and Anchor Objects The Web was based on the notion that the world s information could be strung together by way of the hyperlink the clickable hunk of text or image that navigates an inquisitive reader to a further explanation or related material. Of all the document objects you work with in JavaScript the link is the one that makes that connection. Anchors also provide guideposts to specific locations within documents. As scriptable objects links and anchors are comparatively simple devices. But this simplicity belies their significance in the entire scheme of the Web. And under script control links can be far more powerful than mere tethers to locations on the Web. Link Object In This Chapter Scripting a link to invoke a script function Scripting a link to swap an image on mouse rollovers Triggering actions from double-clicking a link Properties Methods Event Handlers target None onClick text onDblClick x onMouseDown y onMouseOut location object properties onMouseOver onMouseUp Syntax Creating a link object A HREF locationOrURL NAME anchorName TARGET windowName onClick handlerTextOrFunction onDblClick handlerTextOrFunction onMouseDown handlerTextOrFunction 342 Part III JavaScript Object and Language Reference onMouseOut handlerTextOrFunction onMouseOver handlerTextOrFunction onMouseUp handlerTextOrFunction linkDisplayTextOrImage A Accessing link object properties window. index .property About this object JavaScript treats an HTML document link as a distinct object type. When a document loads the browser creates and maintains an internal list in an array of all links defined in the document. When working with a link object in your scripts the JavaScript object world begins to wrap around itself in a way. Despite all the attributes that define a link JavaScript regards a link as the same as a location object Chapter 15 . In other words if you need to refer to a link you can access the same properties of that link the same way you can for any .