...

View Full Version : Plz help!I dont understand these methods



funhunter
02-03-2006, 08:41 AM
hi, I'm a new comer for DOM scripting, I have a piece of code :

function insert_text(text, movestart, moveend)
{
if (document.getElementById)
{
var editbox=document.getElementById('textbox');
}
else if (document.all)
{
var editbox= document.all['textbox'];
}
editbox.focus();
if (typeof(editbox.selectionStart) != 'undefined')
{
var opn = editbox.selectionStart + 0;
editbox.value = editbox.value.substr(0, editbox.selectionStart) + text + editbox.value.substr(editbox.selectionEnd);
if (movestart === false)
{// do nothing }
else if (typeof movestart != 'undefined')
{
editbox.selectionStart = opn + movestart;
editbox.selectionEnd = opn + text.vBlength() - moveend;
}
else
{
editbox.selectionStart = opn;
editbox.selectionEnd = opn + text.vBlength();
}
}
else if (document.selection && document.selection.createRange)
{
var sel = document.selection.createRange();
sel.text = text.replace(/\r?\n/g, '\r\n');
if (movestart === false)
{
// do nothing
}
else if (typeof movestart != 'undefined')
{
sel.moveStart('character', -text.vBlength() +movestart);
sel.moveEnd('character', -moveend);
}
else
{
sel.moveStart('character', -text.vBlength());
}
sel.select();
}
else
{
// failed - just stuff it at the end of the message
editbox.value += text;
}
}

But I dont have any reference for selection, moveStart,MoveEnd, selectionStart and selectionEnd methos or property.I have search in all DOM level2 document.Plz help!

pixelDepth
02-03-2006, 11:04 AM
http://www.mozilla.org/docs/dom/domref/dom_range_ref.html

And

http://www.dotvoid.com/view.php?id=11

Hope they help :)

funhunter
02-04-2006, 11:27 AM
thank very much, I still havent found it.Dont know how to understand that code :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum