}
return !flag;
}
+
+function restoreSelection() {
+ unlocked.focus();
+ if (savedRange != null) {
+ if (window.getSelection)//non IE and there is already a selection
+ {
+ var s = window.getSelection();
+ if (s.rangeCount > 0)
+ s.removeAllRanges();
+ s.addRange(savedRange);
+ }
+ else
+ if (document.createRange)//non IE and no selection
+ {
+ window.getSelection().addRange(savedRange);
+ }
+ else
+ if (document.selection)//IE
+ {
+ savedRange.select();
+ }
+ }
+}
function keypress(e)
{
post = unlocked.innerHTML.substring(j);
if (match == '\\to') {
unlocked.innerHTML = pre + "-> " + post;
- unlocked.focus();
- if (savedRange != null) {
- if (window.getSelection)//non IE and there is already a selection
- {
- var s = window.getSelection();
- if (s.rangeCount > 0)
- s.removeAllRanges();
- s.addRange(savedRange);
- }
- else
- if (document.createRange)//non IE and no selection
- {
- window.getSelection().addRange(savedRange);
- }
- else
- if (document.selection)//IE
- {
- savedRange.select();
- }
- }
-
+ restoreSelection();
return suppressdefault(e,true);
}
+ restoreSelection();
else return suppressdefault(e,false);
}
else return suppressdefault(e,false);