4 var focused_elem
= "{nothing focused}";
6 function setFocusedElem(id
) {
11 function clearFocus() {
16 function getFocusedElement() {
20 function updateLog() {
21 document
.getElementById("log").innerHTML
= "Focused element: " + focused_elem
;
24 function selectLink1() {
26 var sel
= window
.getSelection();
27 var range
= document
.createRange();
28 range
.setStartBefore(document
.getElementById('link1'));
29 range
.setEndAfter(document
.getElementById('link1'));
39 a
<a id=
"link1" href=
"http://www.google.com" onfocus=
"setFocusedElem(this.id)" onblur=
"clearFocus()">link
</a>
40 to
<a id=
"link2" href=
"http://www.google.com" onfocus=
"setFocusedElem(this.id)" onblur=
"clearFocus()">Google
</a>.