Create a "Login" anchor link

Jake Howlett, 26 September 2000

Category: JavaScript; Keywords: Login URL

If you have domino sites that do not explicitly require the user to login, but you want to create a link to let them do so at will, then this may be helpful.....

It makes use of the fact that you can append "&login" to a URL and it will cause the server to authenticate the user.

First, create a link on the form that calls the JavaScript function. You can do this with the following text on the form and mark it as PassThru HTML:

<a href="JavaScript: doLogin()">Login</a>


Now place the following function into your JavaScript library or place it within SCRIPT tags in the document's HEAD.

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;
}
}


You can see this in action, as I have placed a little Padlock at the bottom of every page that lets me Login to CodeStore so that I can administer it easily. You won't, however, be able to login as my password is very hard to guess, but you can see the above function's effect on the URL.

Note: Using this may have adverse effects on any paired URL arguments that your forms use. Beware