code: function()
      {
          var sel = window.getSelection();
          if( ! sel.rangeCount )
              return false;
          var range = sel.getRangeAt(0).cloneRange();
          var rect = range.getBoundingClientRect();
          // Safari 5.1 returns null, IE9 returns 0/0/0/0 if image selected
          if( rect && rect.left && rect.top && rect.right && rect.bottom )
              return {
                  // Modern browsers return floating-point numbers
                  left: parseInt(rect.left),
                  top: parseInt(rect.top),
                  width: parseInt(rect.right - rect.left),
                  height: parseInt(rect.bottom - rect.top)
              };
          // on Webkit 'range.getBoundingClientRect()' sometimes return 0/0/0/0 - but 'range.getClientRects()' works
          var rects = range.getClientRects ? range.getClientRects() : [];
          for( var i=0; i < rects.length; ++i )
          {
              var rect = rects[i];
              if( rect.left && rect.top && rect.right && rect.bottom )
                  return {
                      // Modern browsers return floating-point numbers
                      left: parseInt(rect.left),
                      top: parseInt(rect.top),
                      width: parseInt(rect.right - rect.left),
                      height: parseInt(rect.bottom - rect.top)
                  };
          }
          return false;
      }
docs: http://stackoverflow.com/questions/12603397/calculate-width-height-of-the-selected-text-javascript http://stackoverflow.com/questions/6846230/coordinates-of-selected-text-in-browser-page