focus after some text in a div tag

L

louvino

Hi,

I have :
<div id="obj">Objet :</div>

I want to put the focus AFTER the text "Objet :", is it possible ?

Note : I don't want to create 2 div tags.
 
E

Evertjan.

wrote on 21 mrt 2007 in comp.lang.javascript:
Hi,

I have :
<div id="obj">Objet :</div>

I want to put the focus AFTER the text "Objet :", is it possible ?

Note : I don't want to create 2 div tags.

"focus" can only be "on" a whole html element,
[to make it "clickable" by key <enter>?]

Certainly not "after" an element.

I suppose you could be talking about a cursor.

A cursor can only be applied in a writable element.

Is your div writable?
 
L

louvino

wrote on 21 mrt 2007 in comp.lang.javascript:
I have :
<div id="obj">Objet :</div>
I want to put the focus AFTER the text "Objet :", is it possible ?
Note : I don't want to create 2 div tags.

"focus" can only be "on" a whole html element,
[to make it "clickable" by key <enter>?]

Certainly not "after" an element.

I suppose you could be talking about a cursor.

A cursor can only be applied in a writable element.

Is your div writable?

You're right. I 'm talking about the cursor.

I have : <div id="obj" contentEditable="true" style="border : 1px
solid; width:300px">Objet : </div>

And I want the cursor to be after the semicolon.

Thanks
 
E

Evertjan.

wrote on 21 mrt 2007 in comp.lang.javascript:
You're right. I 'm talking about the cursor.

I have : <div id="obj" contentEditable="true" style="border : 1px
solid; width:300px">Objet : </div>

And I want the cursor to be after the semicolon.

Setting the cursor in a contenteditable div, IE only btw!,
is not a trivial thing, as contenteditable seems a mess in itself.

Perhaps setting a textrange could help, but I doubt it.
 
A

ASM

(e-mail address removed) a écrit :
I have : <div id="obj" contentEditable="true" style="border : 1px
solid; width:300px">Objet : </div>

seems that doesn't work with my Firefox ...
And I want the cursor to be after the semicolon.

and ...

document.getElementById('obj').focus();
document.getElementById('obj').click();

? ? des fois que ... May be ... with IE all is possible ?
 
L

louvino

The code :

<div id="obj" contentEditable="true" style="border : 1px solid; width:
300px">Objet :</div>
<script>
document.getElementById('obj').focus();
document.getElementById('obj').click();
</script>

But not, the cursor is not after "Objet :".

I search only a solution for IE >=6
 
E

Evertjan.

wrote on 22 mrt 2007 in comp.lang.javascript:
The code :

<div id="obj" contentEditable="true" style="border : 1px solid; width:
300px">Objet :</div>
<script>
document.getElementById('obj').focus();
document.getElementById('obj').click();
</script>

But not, the cursor is not after "Objet :".

I search only a solution for IE >=6

[please always quote on usenet]
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top