html5 - contenteditable click anywhere around element and it's selected in Chrome -


in chrome have simple contenteditable="true" span, , if user clicks anywhere around it, cursor shows , he/she can start editing. annoying b/c want cursor show when user clicks on span itself, not outside of it.

example: http://jsbin.com/oyamab/edit#javascript,html,live

html below...

<body>   <span id="hello" contenteditable="true">hello world</span> </body> 

if visit link in chrome, click anywhere in rendered html box (the far right column in jsbin), , can start editing. in firefox on other hand, have click on actual span edit (yay!).

do need accept chrome thing, or there hack around it? thanks.

i suspect it's webkit thing. can work around though making span contenteditable when it's clicked

demo: http://jsfiddle.net/timdown/nv4gp/

html:

<body>   <span id="hello">hello world</span> </body> 

js:

document.getelementbyid("hello").onclick = function(evt) {     if (!this.iscontenteditable) {         this.contenteditable = "true";         this.focus();     } }; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -