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

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -