Christopher Shaw
Christopher Shaw

Reputation: 734

Javascript Posting to Window

I have built up a multiple dimentional array in javascript called myData, I also have a code which opens up a new window and loads the page.

How would I go about Posting the myData array to the new window?

var url = './multi_quote.php';
var win = window.open(url, 'Show Data', 'directories=no,menubar=no,scrollbars=yes,status=no,toolbar=no,location=no,resizable=yes,width=500,height=600');
    if (win.focus) { win.focus(); }

Upvotes: 0

Views: 41

Answers (2)

ArinCool
ArinCool

Reputation: 1738

You can post directly through the URL parameters:

var url = './multi_quote.php?param1='+JSON.stringify(arrayObj);

Or, even better, you can read the array from the child popup window:

var dataArray = window.opener.myData;

So, you need not send the array to the request at all.

Upvotes: 1

Ismail Altunören
Ismail Altunören

Reputation: 270

   function popupwindow (id) {

    var url = './multi_quote.php?quote_id='+id+'';
    var win = window.open(url, 'Show Data', 'directories=no,menubar=no,scrollbars=yes,status=no,toolbar=no,location=no,resizable=yes,width=500,height=600');
        if (win.focus) { win.focus(); }

    }

<a href="#" onclick="popupwindow(1)">Quote 1</a>
<a href="#" onclick="popupwindow(2)">Quote 2</a>

You mean like this i think.

Upvotes: 1

Related Questions