function doLogin() { s = document.location.search; //Check '&Login' not already in URL! if (s.toLowerCase().indexOf("&login") == -1 ) { //Check that there is a '?Open' part to append to a = (s=="") ? "?Open&Login" : "&Login"; document.location.href += a; } }