Sometimes you want to do some user interaction without cluttering up your main window. One easy way to do this is by opening up a new window.
Here's how you can do it.
First, you'll have a main page from which you'll open the new, smaller window.
It could have a form somewhat like this:
[tt]<HTML>
<HEAD>
<TITLE>Your Title</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function popNewWindow() {
window.open("yourpage.html", "popup",
"width=400,height=389,scrollbars=no,menubar=no");
}
//-->
</SCRIPT>
</HEAD>
<BODY>
Open up a new window!"
</BODY></HTML>[/tt]
Then, in an HTML page called "yourpage.html", you can have something like this:
[tt]<HTML>
<HEAD>
<TITLE>Your Pop-up Window</TITLE>
<SCRIPT language="Javascript">
<!--
function closeAndMove() {
window.opener.location.pathname = "/anotherpage.html";
window.close();
}
//-->
</SCRIPT>
</HEAD>
<BODY>
Close this window and change location of opening page
</BODY></HTML>[/tt]
You can also change form elements and other data by referring to the first page as [tt]window.opener[/tt] in the DOM. If you wanted to open a new page in the main window that didn't happen to have the same base URL, then you'd use [tt]window.opener.location.href[/tt] instead of [tt]window.opener.location.pathname[/tt]. Best of luck, and I hope that helps.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.