Jump to content

Recommended Posts

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 by JimFial55
Link to comment
https://forums.phpfreaks.com/topic/270205-popup-window-basics/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/270205-popup-window-basics/#findComment-1389710
Share on other sites

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 by Zane
Link to comment
https://forums.phpfreaks.com/topic/270205-popup-window-basics/#findComment-1389744
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/270205-popup-window-basics/#findComment-1389880
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/270205-popup-window-basics/#findComment-1390905
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.