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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a popup from an existing popup 1

Status
Not open for further replies.

siituser

Programmer
Sep 30, 2002
67
CA
Hi there,

I'm working on an intranet site (so I'm less concerned with the whole use of pop-up thing). One form entry system spawns a pop-up window to work in. I need to spawn another pop-up for a calendar selection. When I try to open a new window, the page just loads in the exisiting window. Is it possible to open a new window from an existing pop-up?

Code:
<SCRIPT LANGUAGE="JavaScript">
var newwin;
function launchwin(winurl,winname,winfeatures)
{
//This launches a new window and then
//focuses it if window.focus() is supported.
newwin = window.open(winurl,winname,winfeatures);
if(javascript_version > 1.0)
{
//delay a bit here because IE4 encounters errors
//when trying to focus a recently opened window
setTimeout('newwin.focus();',100);
}
}
</SCRIPT>

Link: javascript:launchwin('newpopup.htm' , 'newwindow', 'height=300,width=325,screenX=10,screenY=10,left=100,top=90,scrollbars=1');

Thanks in advance
 
Is this the code of your main window?



*cLFlaVA
----------------------------
Breaking the habit...
 
yes - I was trying to reuse it on the newly spawned page. I also tried renaming the script name but that didn't seem to work either.
 
I was able to open a new popup window from an existing popup window easily by calling the window.open() function.

*cLFlaVA
----------------------------
Breaking the habit...
 
Talk about trying to over complicate things! That worked...

But my existing window loaded with [object] on the screen. What else would I place there to keep the existing page there?

Thanks for your prompt reponse.
 
Need code to help. What code is producing the [object] on the screen. You're most likely trying to write something to the document incorrectly.

*cLFlaVA
----------------------------
Breaking the habit...
 
I removed the <script> from a previous post above and changed the link to javascript:window.open('newpage.htm' , 'calendar', 'height=300,width=325,screenX=10,screenY=10,left=100,top=90,scrollbars=1');
 
It's still unclear what you mean. You shouldn't ever remove <script></script tags from around JavaScript. Additionally, you don't need "javascript:" in the beginning of a call to a line of code.

The code you just posted does not cause [object] to be printed to the page...

*cLFlaVA
----------------------------
Breaking the habit...
 
Sorry for being unclear

I removed the complete script code from the header.
I had a "function launchwin" there.

My link is now
<a href="javascript:window.open('newpage.htm' , 'calendar', 'height=300,width=325,screenX=10,screenY=10,left=100,top=90,scrollbars=1');">
<img src="myimage">
</a>

The new window opens correctly but my existing page loads a new screen that says [object] - the header bar is dipslaying the URL from the <a href>
 
Do this:

<a href="newpage.htm" onclick="window.open(this.href, 'calendar', 'height=300,width=325,screenX=10,screenY=10,left=100,top=90,scrollbars=1'); return false;">
<img src="myimage">
</a>


Any better?

*cLFlaVA
----------------------------
Breaking the habit...
 
Thanks a bunch! I'll remember this for next time!
 
Note: in case javascript is disabled on a browser, this will allow the url to still open - in the main window.

*cLFlaVA
----------------------------
Breaking the habit...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top