save and restore selection for modern browsers