I got it to work in IE9 finally by using the following script
NOTE: It doesn't work on html tables. It HAS to be a DIV. So just put a wrapper DIV around the table you need to select!
First I changed the HTML button code a bit:
<input type="button" value="Mark table"    onclick="SelectContent('table1');">  
Then changed the javascript to:
function SelectContent (el) {
var elemToSelect = document.getElementById (el);
        if (window.getSelection) {  // all browsers, except IE before version 9
            var selection = window.getSelection ();
            var rangeToSelect = document.createRange ();
            rangeToSelect.selectNodeContents (elemToSelect);
            selection.removeAllRanges ();
            selection.addRange (rangeToSelect);
        }
    else       // Internet Explorer before version 9
          if (document.body.createTextRange) {    // Internet Explorer
                var rangeToSelect = document.body.createTextRange ();
                rangeToSelect.moveToElementText (elemToSelect);
                rangeToSelect.select ();
        }
  else if (document.createRange && window.getSelection) {         
          range = document.createRange();             
          range.selectNodeContents(el);             
    sel = window.getSelection();     
                  sel.removeAllRanges();             
    sel.addRange(range);              
 }  
}