Click to See Complete Forum and Search --> : Opening up page in existing window


Jon723
10-18-2003, 06:58 PM
Hello, I'm trying to open up another page in the existing window without a new window popping up. Is there a way to get the window.open() method to open up a page inside the existing page?? Thank you in advance

Khalid Ali
10-18-2003, 08:49 PM
instead of window.open use

window.location.href = url;

Jon723
10-20-2003, 02:39 PM
Hello again, I changed my html to the window.location.href statement but I get an error that shows a page with the "page cannot be displayed" message. The url that I assigned is in the same directory as the page that contains the script. Does anybody have a solution to this problem??

fredmv
10-20-2003, 02:41 PM
Can you please provide us with the exact code you're using, or possibly a link so we can see it in action?

Jon723
10-20-2003, 02:47 PM
function ValidateAlum()
{
var alLogin = document.mainform.alname.value;
var alPass = document.mainform.alpass.value;
var password = "password";
var user = "alumni";

if(alLogin == "" || alPass == "")
{
alert("You must enter a userame and/or password");
return false;
}
else if(alLogin != user || alPass != password)
{
alert("Login name and/or password is incorrect");
return false;
}
else
{
window.location.href = "alumniPage.html";
}

return true;
}

fredmv
10-20-2003, 02:52 PM
That looks like it should work, assuming the file alumniPage.html is in the same directory. Make sure it has that exact name too (exact spelling and case). I would also strongly recommend against using JavaScript for something such as this, it's completely insecure; someone could break the security on your site by simply viewing source for valid usernames or passwords. You should consider using a server-side scripting language such as PHP or Perl for this, as it will be much more secure.

Jon723
10-20-2003, 02:53 PM
i know, but this is for a silly class project and I was hardcoding the passwords for testing purposes. Everything will be stored in a secure database.

fredmv
10-20-2003, 03:00 PM
Oh, I see. Well, did you get it to work correctly yet?

Jon723
10-20-2003, 06:36 PM
No!!!! This is really frustrating me. Other functions such as refresh work but changing the page reference is not redirecting the page to what I want it to. Has anyone experienced this problem before and if so how was it resolved??