Scripting XML Elements

Internet Explorer provides limited support for scripting XML elements. For example, I can add an onclick event attribute to an XML element named <xlink> in an XHTML document. (We'll take a look at Xlinks and XHTML later in this book; see Chapters 15, 16, and 17.)

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet TYPE="text/css" href="xlink.css"?>

<!DOCTYPE html SYSTEM "t3.dtd">
<html>
    <head>
    </head>

    <body>
    Want to check out <xlink xml:link = "simple" inline="false"
    href = "http://www.w3c.org"
    onclick="location.href='http://www.w3c.org'">W3C</xlink>?
    </body>
</html>

I can specify in a style sheet, xlink.css, that <xlink> elements should be displayed in blue and underlined, as a hyperlink might appear, and I can also specify that the mouse cursor should change to a hand when over this element, just as it would for an HTML hyperlink:

xlink {color: #0000FF; text-decoration: underline; cursor: hand}

The results appear in Figure 7.10—when the user clicks the <xlink> element, Internet Explorer executes the code in the onclick event attribute. In this case, that navigates the browser to http://www.w3c.org. As you can see, you can script XML elements in Internet Explorer, adding event attributes such as onclick.

Figure 7.10. Creating a "hyperlink" in an XML document in Internet Explorer.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset