internet explorer - Javascript select text with create range doesn't work in IE -
i have javascript function select content of cell (html table) onclick="select_cell(this)". no surprise, works fine everywhere except ie. weird part discovered if set timeout, works... 100 ms not enough: working half time. 200 ms, it's working great!
function select_cell(element){ if (window.getselection) { var range = document.createrange(); settimeout(function(){ range.selectnode(element); window.getselection().addrange(range); }, 200); } else if (document.selection) { var range = document.body.createtextrange(); range.movetoelementtext(element); range.select(); } } the thing don't timeout. has explanation? or better, solution skip timeout?
i posted here answer text selection, may helpful you, check this out
Comments
Post a Comment