Involves the Quick access key (accesskey property) feature:
Add the following code to the HTML page:
<ul id= "Navigation" > <li><a href= " Ape Group Education " accesskey= "1" >Home</a></li> <li><a href= "search.html" accesskey= "4" >search</a></li> <li><a href= " Contact.html "accesskey=" 9 ">contact</a></li></ul>
JS Add a method to display:
function Displayaccesskeys () {if (!document.getelementsbytagname | |!document.createelement | |! document.createTextNode) return false; var ul = document.getElementById ("navigation"); var links = ul.getelementsbytagname ("a"); var Akeys = new Array (); for (Var i=0;i<links.length;i++) {if (!links[i].getattribute ("accesskey")) continue; var key = Links[i].getattribute ("accesskey"); var text = Links[i].lastchild.nodevalue; Akeys[key] = text; } var list = document.createelement ("ul"); For (key in Akeys) {var text = Akeys[key]; var str = key + ":" + text; var item = document.createelement ("Li"); var item_text = document.createTextNode (str); Item.appendchild (Item_text); List.appendchild (item); } var Header = document.createelement ("h3"); var header_text = document.createTextNode ("Accesskeys"); Header.appendchild (Header_text); Document.body.appendChild (header); Document.body.appendCHild (list);}
Note: JavaScript scripts should only be used to enrich the contents of the document, avoiding the use of DOM technology to directly insert core content.
JavaScript DOM Programming Art