JimFial55 Posted November 2, 2012 Share Posted November 2, 2012 (edited) I'm self taught and this is probably a basic question. Trying to use two popup windows in one webpage. First popup used opens correctly, but second one opens as full page. In the following script on the main page: <SCRIPT TYPE="text/javascript"> <!-- function popupnr(mylink, windowname, refocus) { var mywin, href; if (typeof(mylink) == 'string') href=mylink; else href=mylink.href; mywin = window.open('', windowname, 'width=400,height=400,resizable=yes,scrollbars=yes'); // if we just opened the window if ( mywin.closed || (! mywin.document.URL) || (mywin.document.URL.indexOf("about") == 0) ) mywin.location=href; else if (refocus) mywin.focus(); return false; } //--> </SCRIPT> I think I've figured out that I have to use one instance of this for each popup with each specific popup name being inserted for windowname . The windowname then comes from the link line: <A HREF="provided_image.htm" onclick="return popupnr(this, 'windowname')">Your Image</A> Ready? Is this correct? Edited November 2, 2012 by JimFial55 Quote Link to comment https://forums.phpfreaks.com/topic/270205-popup-window-basics/ Share on other sites More sharing options...
Adam Posted November 2, 2012 Share Posted November 2, 2012 Looks okay. Could you post the two calls you have? Quote Link to comment https://forums.phpfreaks.com/topic/270205-popup-window-basics/#findComment-1389702 Share on other sites More sharing options...
JimFial55 Posted November 2, 2012 Author Share Posted November 2, 2012 Read your "Best Practices" and took off the <!--/-->. if you could go to: http://kickstandpad.net/index.htm Click on "Your Provided" in first blue box, it comes up as popup. If you then click "Order Process" under main heading, it comes up as a new page, not a popup. Now I'm thinking I should remove the coding after from "// to } " as this is causing no more popups to occur. Quote Link to comment https://forums.phpfreaks.com/topic/270205-popup-window-basics/#findComment-1389710 Share on other sites More sharing options...
JimFial55 Posted November 2, 2012 Author Share Posted November 2, 2012 (edited) Okay,here's what Ive got on the main webpage: <SCRIPT TYPE="text/javascript"> function popupnr(mylink, orderprocess, refocus) { var mywin, href; if (typeof(mylink) == 'string') href=mylink; else href=mylink.href; mywin = window.open('', orderprocess, 'width=600,height=400,resizable=yes,scrollbars=yes'); // if we just opened the window if ( mywin.closed || (! mywin.document.URL) || (mywin.document.URL.indexOf("about") == 0) ) mywin.location=href; else if (refocus) mywin.focus(); return false; } // </SCRIPT> <SCRIPT TYPE="text/javascript"> function popupnr(mylink, providedimage, refocus) { var mywin, href; if (typeof(mylink) == 'string') href=mylink; else href=mylink.href; mywin = window.open('', providedimage, 'width=400,height=400,resizable=yes,scrollbars=yes'); // if we just opened the window if ( mywin.closed || (! mywin.document.URL) || (mywin.document.URL.indexOf("about") == 0) ) mywin.location=href; else if (refocus) mywin.focus(); return false; } // </SCRIPT> Then at each link location: What is the <a href="order_process.htm" onclick="return popupnr(this, 'orderprocess')">Order Process</a> ? and <a href="provided_image.htm" onclick="return popupnr(this, 'providedimage')">You provide</a Each line is at separate location. In the <body> section of the popup pages is: <SCRIPT TYPE="text/javascript"> function targetopener(mylink, closeme, closeonly) { if (! (window.focus && window.opener))return true; window.opener.focus(); if (! closeonly)window.opener.location.href=mylink.href; if (closeme)window.close(); return false; } // </SCRIPT> somewhere in this, ther's something causing this problem. Edited November 3, 2012 by Zane Quote Link to comment https://forums.phpfreaks.com/topic/270205-popup-window-basics/#findComment-1389744 Share on other sites More sharing options...
Adam Posted November 3, 2012 Share Posted November 3, 2012 Can you please post your code in tags in future, makes it much easier to read. Okay anyway. You're redeclaring the function unnecessarily, you should be reusing the function instead. Though that shouldn't be the cause of the issue. Is it when you call the function for the second time, or one of the specific links? Quote Link to comment https://forums.phpfreaks.com/topic/270205-popup-window-basics/#findComment-1389880 Share on other sites More sharing options...
JimFial55 Posted November 4, 2012 Author Share Posted November 4, 2012 It's just when I call the function for the second time. The first instance of popup works fine. Quote Link to comment https://forums.phpfreaks.com/topic/270205-popup-window-basics/#findComment-1390117 Share on other sites More sharing options...
JimFial55 Posted November 7, 2012 Author Share Posted November 7, 2012 I figured out where my mistake was. It was in the <!DOCTYPE> Needed to use: [size="2"]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">[/size] [size="2"] [/size] as Doc Type. This fixed the problem. Can now open several popups from the same page. Quote Link to comment https://forums.phpfreaks.com/topic/270205-popup-window-basics/#findComment-1390905 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.