1 | <html> |
---|
2 | <head> |
---|
3 | <title>Jumping cursor in Opera</title> |
---|
4 | <script type="text/javascript"> |
---|
5 | function splitCursor() |
---|
6 | { |
---|
7 | r = sel.getRangeAt(0); |
---|
8 | var endNode = r.endContainer; |
---|
9 | if (endNode.nodeType == 3 && endNode.nodeValue.length > 0) |
---|
10 | { |
---|
11 | endNode.splitText(r.endOffset); |
---|
12 | setTimeout(splitCursor, 1000) ; |
---|
13 | } |
---|
14 | } |
---|
15 | |
---|
16 | function init() |
---|
17 | { |
---|
18 | document.designMode = "on"; |
---|
19 | window.sel = getSelection(); |
---|
20 | window.r = sel.getRangeAt(0); |
---|
21 | r.selectNodeContents(document.getElementById("para")) ; |
---|
22 | r.collapse(false) ; |
---|
23 | sel.removeAllRanges(); |
---|
24 | sel.addRange(r); |
---|
25 | setTimeout(splitCursor, 1000); |
---|
26 | } |
---|
27 | </script> |
---|
28 | </head> |
---|
29 | <body onload="init();"> |
---|
30 | <p id="para">Look! The caret jumps <span>around</span> in Opera!</p> |
---|
31 | </body> |
---|
32 | </html> |
---|