F
fulio pen
Please open the following page:
http://www.pinyinology.com/content/content3c.html
And press F5 to restart the procedure in the 'typing zone'. The word
disappears and reappears. I like to see this procedure also happens
to the text in the 'listing zone', that is, they disappear and
reappear when pressing F5. The javascript code is in the head area,
but i am pasting some below. Please let me know anything else I need
to do to present my question. Thanks for your help.
function KeyDown()
{
var key=window.event.keyCode;
if (key==8)
{
window.event.returnValue=false;
var r=document.selection.createRange();
r.collapse(false);
r.move("character",-1);
r.collapse(false);
var p=r.parentElement();
if (p.nodeName.toLowerCase()=="sup"){
p.outerHTML="";
return;
}
window.event.returnValue=true;
}
}
function KeyPress()
{
var key=window.event.keyCode;
window.event.returnValue=false;
if (key>=48 && key<=57)
{
var r=document.selection.createRange();
r.collapse(false);
var d=r.duplicate();
d.moveStart("character",-1);
var c=d.text;
var p=d.parentElement();
var b=/[A-Za-z]/.test(c);
//b=b || p.nodeName.toLowerCase()=="sup";
if (b)
{
d.collapse(false);
var s=String.fromCharCode(key);
s=(p.nodeName.toLowerCase()=="sup")? s:"<SUP>"+s+"</SUP>";
d.pasteHTML(s);
d.collapse(false);
d.select();
return;
}
}
if (!(key in {37:1,38:1,39:1,40:1}))
{
var r=document.selection.createRange();
r.collapse(false);
p=r.parentElement();
if (p.nodeName.toLowerCase()=="sup")
{
var s=p.outerHTML;
p.removeNode(true);
r.pasteHTML(s);
r.collapse(false);
r.select();
}
}
window.event.returnValue=true;
}
http://www.pinyinology.com/content/content3c.html
And press F5 to restart the procedure in the 'typing zone'. The word
disappears and reappears. I like to see this procedure also happens
to the text in the 'listing zone', that is, they disappear and
reappear when pressing F5. The javascript code is in the head area,
but i am pasting some below. Please let me know anything else I need
to do to present my question. Thanks for your help.
function KeyDown()
{
var key=window.event.keyCode;
if (key==8)
{
window.event.returnValue=false;
var r=document.selection.createRange();
r.collapse(false);
r.move("character",-1);
r.collapse(false);
var p=r.parentElement();
if (p.nodeName.toLowerCase()=="sup"){
p.outerHTML="";
return;
}
window.event.returnValue=true;
}
}
function KeyPress()
{
var key=window.event.keyCode;
window.event.returnValue=false;
if (key>=48 && key<=57)
{
var r=document.selection.createRange();
r.collapse(false);
var d=r.duplicate();
d.moveStart("character",-1);
var c=d.text;
var p=d.parentElement();
var b=/[A-Za-z]/.test(c);
//b=b || p.nodeName.toLowerCase()=="sup";
if (b)
{
d.collapse(false);
var s=String.fromCharCode(key);
s=(p.nodeName.toLowerCase()=="sup")? s:"<SUP>"+s+"</SUP>";
d.pasteHTML(s);
d.collapse(false);
d.select();
return;
}
}
if (!(key in {37:1,38:1,39:1,40:1}))
{
var r=document.selection.createRange();
r.collapse(false);
p=r.parentElement();
if (p.nodeName.toLowerCase()=="sup")
{
var s=p.outerHTML;
p.removeNode(true);
r.pasteHTML(s);
r.collapse(false);
r.select();
}
}
window.event.returnValue=true;
}