PDA

View Full Version : window.open() interaction



ikkeook
13 May 2008, 6:07 AM
I have made a shopping cart (grid - buttons to pay , ...) = main window (=application)

Now, i click on the pay button an I open a new window for the pay-site (moneybookers) = 2e window.

urlToOpen = 'moneybookers.php?amount='+carttotalprice;
window.open(urlToOpen,"newpaywindow","menubar=1,resizable=1,width=350,height=250");

Payment is processed by Moneybookers AND the shopping Cart in the main indow needs to update.
How can I do that? I tried some possible solution, but nothing worked out:

1) in 2e window:

<script type="text/javascript">opener.someFunction();</script>

->Problem with the scope I guess. I've declared the function inside another method (page) . As such, it's only available inside that scope.

2) in main window:

Ext.EventManager.on(newpaywindow, 'unload', doFunction()); -> error because newpaywindow in not created yet, so undeffined

Who can help?

Gordon76
13 May 2008, 9:36 AM
urlToOpen = 'moneybookers.php?amount='+carttotalprice;

I do not know what moneybookers.php does, but sending the cart total price via the URL sounds like a pretty bad idea to me, unless you want people to shop for free.

13 May 2008, 9:38 AM
Welcome to the forums. Please post your relevant code with indentation in PHP or code tags. we can only guess what's going on ... until you show us a full pictures.

hendricd
13 May 2008, 10:52 AM
urlToOpen = 'moneybookers.php?amount='+carttotalprice;
var newpaywindow = window.open (urlToOpen,"newpaywindow","menubar=1,resizable=1,width=350,height=250");
permits:
Ext.EventManager.on(newpaywindow, 'unload', doFunction());

<script type="text/javascript">opener.someFunction();</script>
parent window function must not be declared anonymously:

function someFunction(){...}but, this way:

someFunction = function(){...}

ikkeook
15 May 2008, 11:14 AM
PROBLEM Solved:

In main application:
* First the action to start the payment:
var payMoneybookers = new Ext.Action({
text: 'Moneybookers',
handler: function(){
Ext.example.msg('Click','You clicked on "Moneybookers".');
urlToOpen = 'moneybookers.php?amount='+carttotalprice;
var newpaywindow = window.open(urlToOpen,"newpaywindow","menubar=1,resizable=1,width=350,height=250");
}
});

* when the payment is done I need to update the cart:
masking = function(){
Ext.get(document.body).mask('Updating cart!!');
DataStoreCart.reload();
setTimeout('Ext.get(document.body).unmask()', 2000);
}


In the window.open page:
<A HREF=""
onClick="opener.masking();";>CLICK HERE</A>

When I click the link, the shopping cart in main page get updated!

GREAT!! Thanks!!

_____________________
urlToOpen = 'moneybookers.php?amount='+carttotalprice;

"I do not know what moneybookers.php does, but sending the cart total price via the URL sounds like a pretty bad idea to me, unless you want people to shop for free"
Yes I know. This was only for testing. It will be completely on the server side!!