• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1152
  • Last Modified:

Javascript Close Popup and Redirect Parent

This is my first time using my points so forgive if my question is lacking in information.

What I am trying to do is I have a popup window that opens in my shopping cart.  There are a list of links that the user can click on in this popup, but they all go to basically the same place (cart.php?partner=partnername).  What I need to have happen is when the user clicks the link that it loads that link in the parent page and closes the popup. I have it working in Firefox, but IE only closes the window and doesnt change the parent page. Additionally when the page does change/reload, the popup comes back because the page is still cart.php but just with different information after the ?

Here is the code I have to open the popup:
<script language="javascript">
window.name = "main";

function popUp(URL) {
day = new Date();
id = day.getTime();

eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=250,height=250,left = 200,top = 200');");
}
javascript:popUp('consultant_select.php')

</script>

This is one of the links that are in the popup window:
<a href="javascript:;" target="main" onClick="opener.location='http://www.mysite.com/store/cart.php?partner=joe_smith&bid=1';window.close();">

If you need more info please ask.  Also, if someone could tell me if the amount of points given is appropriate..I dont want to short anyone :-)
0
koolie
Asked:
koolie
  • 5
  • 4
1 Solution
 
koolieAuthor Commented:
Just a quick update:  I can get the exact same "onClick" code to work if I put it in a button, which is kind of okay but I would much so prefer a link...So the more important of the two issues is getting that link to only popup once.  Thanks
0
 
dukestaTAICommented:
This page has a work around for MSIE.

http://jennifermadden.com/javascript/windowClose.html


Good luck,
0
 
dukestaTAICommented:
Here is a cleaner approach, and the full code, just cut, paste and try this one.

<html>
<head>
<script type="text/javascript">
function open_win()
{
window.open("http://www.w3schools.com");
this.focus();
self.opener = this;
self.close();
}
</script>
</head>

<body>
<form>
<input type=button value="Open Window" onclick="open_win()">
</form>
</body>

</html>
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
koolieAuthor Commented:
It's not as much an issue of getting the window to close.  I can get that done by using window.close().  What I cant get it to do is go to the new page and then close.  Thank you though...
0
 
dukestaTAICommented:
I don't understand, youwant to open a new window and then close it?
0
 
koolieAuthor Commented:
I like the cleaner code, but I have to have this page pop open onload.  My client is concerned that if I leave it up to a user to click a button, that they wont do it.  However, could this be put into an onload event in the body tag?
0
 
koolieAuthor Commented:
The window will popup from the cart page.  The links that are inside the popup contain values after the .php? that will say who gets commission for the sale.

So  cart.php loads -->popup opens -->user clicks who gets the commision -->popup closes --> cart.php loads the link that was clicked in the popup
0
 
dukestaTAICommented:
Have you tried this?

<a href="javascript:;" target="main" onClick="opener.location='http://www.mysite.com/store/cart.php?partner=joe_smith&bid=1';this.focus();self.opener = this;self.close();">
0
 
koolieAuthor Commented:
IE Still didnt like it....i dunno... The world would be a much better place if IE just floated away; however, I have managed to resolve my issue for the most part.  I still cant get to work with an <a> tag and in IE, but the buttons should be fine.  I only have 8 of them and buttons are a little more prominent anyway.  I appreciate the help and if you do by change figure it out please post it as I may need it later, but for the effort I'll throw the points u'r way...Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now