Ok, there is a new problem. Here is the code:
HTML Code:
<body onLoad="redirect();init();verify();">
<script type="text/javascript">
function redirect() {
if (window.location.search.length <= 1) {
alert("You need a username and password")
window.location="password_page_1.html"
}
}
//
// That works fine, but it will still redirect if there is an "?". I don't exactly want that...
//
function init() {
var names = location.search.substring(1,location.search.length).split('&');
var UserName = names[0].substring(names[0].lastIndexOf('=')+1,names[0].length);
var Password = names[1].substring(names[1].lastIndexOf('=')+1,names[1].length);
document.getElementById("UserName").value = UserName;
document.getElementById("Password").value = Password;
}
function verify() {
var UserName = document.getElementById("UserName");
var Password = document.getElementById("Password");
if (UserName.value=="WD") {
if (Password.value=="JavaScript") {
alert("Correct!")
} else {
alert("Invalid Password")
window.location="password_page_1.html"
}
} else {
alert("Invalid Username")
window.location="password_page_1.html"
}
}
</script>
<form>
<input type=text name=UserName class=hidden id=UserName>
<input type=text name=Password class=hidden id=Password>
</form>
</body>
The problem is that it won't do anything if the URL is, say, "?hi" but will if it's "?" or "?username=&password=".
What do I do?
What I want it to do is redirect unless there is "?username=WD&password=JavaScript" at the end of the URL.
Bookmarks