BoolNordicAB / sharepoint-utilities

Makes client side SharePoint a bit nicer to work with (that's the plan, at least)
https://boolnordicab.github.io/sharepoint-utilities/doc/index.html
MIT License
14 stars 3 forks source link

add text selecting function #30

Closed roobie closed 8 years ago

roobie commented 9 years ago

http://stackoverflow.com/a/2838358

  var selectElementText = function selectElementText(el, win) {
    win = win || window;
    var doc = win.document, sel, range;
    if (win.getSelection && doc.createRange) {
      sel = win.getSelection();
      range = doc.createRange();
      range.selectNodeContents(el);
      sel.removeAllRanges();
      sel.addRange(range);
    } else if (doc.body.createTextRange) {
      range = doc.body.createTextRange();
      range.moveToElementText(el);
      range.select();
    }
  };