Hi all,
Does anyone have an idea how can we insert some text AT THE CURRENT LOCATION OF THE TEXT CURSOR in a text box (IE 5.x)? Any help is highly appreciable.
I'm not sure what you mean, if your looking for a way to have text pre-entered into a Text Box, you can use...
<INPUT TYPE="text" NAME="textbox1" VALUE="Put pre-entered text here.">
The value (same for most input forms) places that assigned value in the form. Jonathan Hannan
Computer Repair, Webdesign
HTML, CGI, PERL, JavaScript, XML
<SCRIPT LANGUAGE="JavaScript">
var Xcoord, Ycoord;
var isNav, isIE;
var menu;
//-
//- Check for the key stroke event looking for the "{" key.
//-
function showMenu (evt) {
// alert("made it to showMenu"
if (document.all) {
//alert("in document.all"
//document.all.contextMenu.style.pixelLeft = event.clientX;
//document.all.contextMenu.style.pixelTop = event.clientY;
document.all.contextMenu.style.pixelLeft = Xcoord;
document.all.contextMenu.style.pixelTop = Ycoord;
document.all.contextMenu.style.visibility = 'visible';
return false;
}
else if (document.layers) {
if (evt.which == 3) {
alert("in evt.which 3"
// djm -- document.contextMenu.left = evt.x;
// djm -- document.contextMenu.top = evt.y;
document.contextMenu.left = Xcoord;
document.contextMenu.top = Ycoord
document.contextMenu.onmouseout =
function (evt) { this.visibility = 'hide'; };
document.contextMenu.visibility = 'show';
return false;
}
}
return true;
}
//-
//- Well, I guess this is fall through logic for now.
//-
if (document.all)
{
document.oncontextmenu =showMenu;
} // end of document.all
if (document.layers)
{
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = showMenu;
}// end of document.layers
//-
//- Check for the key stroke event looking for the "{" key.
//-
function PasteIt(id)
{
//-
//- for through the loop
//-
for (var i = 0; i < document.anchors.length; i++) // was links
{
if (i == id)
{
document.letter_form.pasteText.value = document.anchors.name;
var Range1 = document.letter_form.pasteText.createTextRange();
} // end if the for nteger is equal to id number passed.
} // end for statement through anchors collection.
Range1.execCommand("Copy"
//-
//- set the range and paste the button contents at the offset
//- set by the user.
//-
//for (i=0;i< parent.frames.length;i++)
//{
//alert("text ["+parent.frames.name+"]" );
//if (parent.frames.name == "mainFrame"
//{
// Range = parent.frames.letter_form.txt_letter_text.createTextRange();
//}
//}
//window.clipboardData.setData("Text", pasteText);
//btnRange.execCommand("Copy"
Range = document.letter_form.mytextarea.createTextRange();
//Range.select();
offsetX = Xcoord;
offsetY = Ycoord;
Range.moveToPoint(offsetX,offsetY);
alert("Range.length ["+Range.length+"]"
for (var i=0; i > Range.length; i++)
{
alert("i ["+i+"]"
}
//Range.expand("word"
//Range.select();
//Range.collapse(false);
Range.execCommand("Paste"
document.onkeypress = null;
return false; // do not submit the form
}// end of function
//-
//- when the user sets the mousedown event in the textarea... grab the
//- X and Y coordinates.
//-
function setXY()
{
Xcoord = window.event.x;
Ycoord = window.event.y;
}
//-
//- Check for the key stroke event looking for the "{" key.
//-
function checkKey(evt)
{
if (isNav)
{
theBtnOrKey = evt.which;
} // end of if isNav
if (window.event.srcElement.type == "textarea"
{
//alert("window.event.KeyCode " + window.event.keyCode);
if (window.event.keyCode == 123) // check for "{" keystroke
{
//alert("window.event.KeyCode " + window.event.keyCode);
if (document.all)
{
Xcoord = window.event.x;
Ycoord = window.event.y;
document.onkeypress = showMenu;
} // end of if document.all
if (document.layers)
{
//alert ("made it 2"
document.captureEvents(event.KEYPRESS);
document.onkeypress = showMenu;
} // end of document.layers
} // end of window.event.keyCode
} // end of window.event.srcElement.type
} // end of function
</SCRIPT>
</head>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.