javascript - Chrome execCommand returns error -
how use execcommand() in chrome? here code have right being used insert special character when hitting tab button
function editable(supr){ document.getelementbyid('codeline').contenteditable='true'; document.getelementbyid('codeline').onkeydown=function(e) { if(e.keycode==9){ e.preventdefault(); range1 = document.getelementbyid('codeline'); range1.execcommand("inserthtml",false,"p"); } } }
the execcommand()
method method of document
objects, not elements. ie provides execcommand()
method of textrange
, controlrange
objects, these not present in other browsers.
document.execcommand("inserthtml", false, "p");
you may want consider happens if user presses tab key when user has selected text: in case you'd want delete contents of selection before inserting tab character.
Comments
Post a Comment