View Single Post
Old 08-14-2012, 07:41 AM   PM User | #3
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Thanks fir the reply, but it doesn't work completely.

I've tried it like
Code:
<li onclick="injectString( this.innerHTML);">½</li>
Code:
function injectString(str){
   var sel=frames[0].getSelection()
   var nd=sel.anchorNode;
   var txt=nd.data+'';
   var pos=sel.anchorOffset||0;
   sel.anchorNode.data=txt.slice(0,pos)+str+txt.slice(pos);
 }
Edit: It inserts ½ to the iframe, when there's something already typed there.

Looks like, it doesn't insert the symbol to the end of what originally typed. I need to either select some text or put the cursor in between two characters to get it work.


Edit: Also, it moves the cursor to the beginning of the typing area, after button click

I've updated the demo page at http://itsnot.freehostia.com/wysihtm...ihtml5-new.htm
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

Last edited by abduraooft; 08-14-2012 at 08:03 AM..
abduraooft is offline   Reply With Quote