Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change page with a function.

Status
Not open for further replies.

yolond

Technical User
Jan 5, 2001
9
I haven't known javascript that long, but I must have gone brain dead because I'm sure this is an easy task.

I have a function that if conditions return true, will open up a new page in a pop-up window. How do I also get it to change the page in the current window?
 
window.location="page1.htm" jared@aauser.com
 
Hmm, I tried that. I still get my pop-up window, but the main window remains changed. Here's the code:

if (form.emailaddr.value == ""){
alert('Email address required to play.');
form.emailaddr.focus();
return false;
}
else{
window.open(theLocation,'newWin','height=520,width=760,scrollbars=1,location=0');
window.location=" return true;
}
 
Nope. That didn't work either. =(
 
i assume you are doing this in the onsubmit handler. try this instead:

function thesub()
{
if (document.formname.emailaddr.value == ""){
alert('Email address required to play.');
document.formname.emailaddr.focus();
return false;
}
else{
window.open(" window.location=" return false;
}
}

</script>

<form name=&quot;formname&quot;>
<input name=&quot;emailaddr&quot;><input type=&quot;button&quot; onClick=&quot;thesub()&quot;>
</form> jared@aauser.com
 
no, I think he was doing it onsubmit and it was just refreshing the page because he was returning true i think jared@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top