Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Putting a cusor in normal text

Reply
Thread Tools

Putting a cusor in normal text

 
 
dedejavu@hotmail.com
Guest
Posts: n/a
 
      07-26-2005
Hi all you JS experts,
Is there any way to put a blinking ibeam cursor in middle of td text -
the same way it would blink if I clicked in the middle of the text in a
text input? To further explain, I can highlight any text on an HTML
page by dragging, but if I just click I get no ibeam cursor (obviously
because I am not supposed to be able to edit). Is there anyway to get
one to sit there and blink where-ever I click on the page.
Thanks for your help
Pachydermitis

 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      07-26-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi all you JS experts,
> Is there any way to put a blinking ibeam cursor in middle of td text -
> the same way it would blink if I clicked in the middle of the text in a
> text input? To further explain, I can highlight any text on an HTML
> page by dragging, but if I just click I get no ibeam cursor (obviously
> because I am not supposed to be able to edit). Is there anyway to get
> one to sit there and blink where-ever I click on the page.
> Thanks for your help
> Pachydermitis


You can set it very easy for IE by using contenteditable attribute
(note that you cannot set table cell itself to contenteditable, so you
need a div wrapper).

<html>
<head>
<title>contentEditable</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style type="text/css">
body { background-color: #FFFFFF}
td div { font: 10pt Verdana, Helvetica, sans-serif; height: auto;
width: 100%}
</style>
</head>
<body>
<table width="75%" cellpadding="10" cellspacing="0" border="1">
<tbody>
<tr>
<td width="33%"><div contenteditable="true">empty</div></td>
<td width="34%"><div contenteditable="true">empty</div></td>
<td width="33%"><div contenteditable="true">empty</div></td>
</tr>
<tr>
<td><div contenteditable="true">empty</div></td>
<td><div contenteditable="true">Lorem ipsum dolor sit amet,
consectetuer
adipiscing elit. Phasellus in sem lacinia nunc rutrum tempor. Vivamus
facilisis.
Vivamus lectus eros, aliquet id, tincidunt in, tempus quis, erat. Etiam
scelerisque
sem et massa. Cum sociis natoque penatibus et magnis dis parturient
montes, nascetur
ridiculus mus. Ut at arcu. Praesent et turpis ac urna ornare hendrerit.
Mauris
vitae pede a libero scelerisque egestas. Nunc sollicitudin, orci et
commodo ultrices,
nisl libero vulputate urna, in posuere ligula arcu ut libero. In
ullamcorper neque
ut mi.</div></td>
<td><div contenteditable="true">empty</div></td>
</tr>
<tr>
<td><div contenteditable="true">empty</div></td>
<td><div contenteditable="true">empty</div></td>
<td><div contenteditable="true">empty</div></td>
</tr>
</tbody>
</table>
</body>
</html>

I guess you can emulate this on Firefox using document.designMode
property.

Opera and Safary (at least) do not have the necessary TextRange
methods. So you can get the selection using document.getSelection(),
but you cannot reliably attach it to the particular place in the
document (find the corresponding DOM block).

 
Reply With Quote
 
 
 
 
Pachydermitis
Guest
Posts: n/a
 
      07-26-2005
- Hope this isn't a repeat post the first died -
VK you're awesome - this works even better than I had hoped - with much
less work on my part.
Lorem ipsum threw me for a minute; I knew it looked familiar, thought
it was Latin, and looked it up . . duh do I feel like an uneducated
clod.
Thanks for the help
Pachydermitis

 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      07-26-2005
Pachydermitis wrote:
> - Hope this isn't a repeat post the first died -
> VK you're awesome - this works even better than I had hoped - with much
> less work on my part.
> Lorem ipsum threw me for a minute; I knew it looked familiar, thought
> it was Latin, and looked it up . . duh do I feel like an uneducated
> clod.
> Thanks for the help
> Pachydermitis


"Lorem ipsum" is the standard bogus text to use as placeholder. It's a
"pseudo-Latin" - composed of Latin words but means nothing. I hope you
did try to translate it!

 
Reply With Quote
 
Robert
Guest
Posts: n/a
 
      07-28-2005
VK wrote:
> (E-Mail Removed) wrote:
>
>>Hi all you JS experts,
>>Is there any way to put a blinking ibeam cursor in middle of td text -

>
> You can set it very easy for IE by using contenteditable attribute


Do you happen to know if something like that is possible for
Mozilla/Firefox?
 
Reply With Quote
 
RobG
Guest
Posts: n/a
 
      07-28-2005
Robert wrote:
> VK wrote:
>
>> (E-Mail Removed) wrote:
>>
>>> Hi all you JS experts,
>>> Is there any way to put a blinking ibeam cursor in middle of td text -

>>
>>
>> You can set it very easy for IE by using contenteditable attribute

>
>
> Do you happen to know if something like that is possible for
> Mozilla/Firefox?


<URL:http://www.mozilla.org/editor/ie2midas.html>

--
Rob
 
Reply With Quote
 
Pachydermitis
Guest
Posts: n/a
 
      08-03-2005
Yes - the fact that it is the standard bogus placeholder text for
typesetting came painfully back to memory - after I tried to translate
it.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I get the text under the cusor ? Bo Yang Python 0 04-07-2006 04:20 PM
Dynamic Cusor co-ordinates at the mouse cursor... Domestos HTML 5 10-06-2005 09:32 PM
Putting Dynamic Text Where I Want It Rehor ASP .Net 2 10-22-2004 02:16 PM
Difference between putting code in constructor and putting code in static{} Saurabh Java 6 05-30-2004 02:44 PM
javascript for putting text in an asp.net edit control Michelle Stone ASP .Net 1 10-15-2003 10:44 AM



Advertisments