Putting a cusor in normal text

D

dedejavu

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
 
V

VK

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).
 
P

Pachydermitis

- 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
 
V

VK

Pachydermitis said:
- 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! :)
 
P

Pachydermitis

Yes - the fact that it is the standard bogus placeholder text for
typesetting came painfully back to memory - after I tried to translate
it. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top