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)
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.
The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values.
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).
they listed second parameter as name and it accepts following values: name Optional. Specifies the target attribute or the name of the window.
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.'); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With