Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript window.open pass values using POST

I have a javascript function that uses window.open to call another page and returning the result.

Here is the section of my code:

var windowFeatures = "status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=1, scrollbars=1"; window.open ('http://www.example.com/index.php?p=view.map&coords=' + encodeURIComponent(coords), 'JobWindow', windowFeatures); 

My problem now is that I am passing too much data for the GET to handle and I need to pass it using the POST method.

How can I convert the code above to open the page using the POST method without implement forms all over the page (the page lists 100's of orders with a list of suppliers - I am trying to map the suppliers)

like image 888
php-b-grader Avatar asked Apr 16 '11 03:04

php-b-grader


People also ask

How do I pass a variable in windows open?

Passing variables between the windows (if your windows are on the same domain) can be easily done via: Cookies. localStorage. Just make sure your browser supports localStorage, and do the variable maintenance right (add/delete/remove) to keep localStorage clean.

How do I open a new window in Javascript?

The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values.

What is the second parameter of window open () method?

URL: This optional parameter of the window. open() function contains the URL string of a webpage, which you want to open. If you do not specify any URL in this function, it will open a new blank window (about:blank).

What is the second parameter of window open in Javascript?

they listed second parameter as name and it accepts following values: name Optional. Specifies the target attribute or the name of the window.


1 Answers

I used a variation of the above but instead of printing html I built a form and submitted it to the 3rd party url:

    var mapForm = document.createElement("form");     mapForm.target = "Map";     mapForm.method = "POST"; // or "post" if appropriate     mapForm.action = "http://www.url.com/map.php";      var mapInput = document.createElement("input");     mapInput.type = "text";     mapInput.name = "addrs";     mapInput.value = data;     mapForm.appendChild(mapInput);      document.body.appendChild(mapForm);      map = window.open("", "Map", "status=0,title=0,height=600,width=800,scrollbars=1");  if (map) {     mapForm.submit(); } else {     alert('You must allow popups for this map to work.'); } 
like image 169
php-b-grader Avatar answered Sep 22 '22 13:09

php-b-grader