Performing A Post In Window.open()
I'm trying to open a popup and I'd like to send data using the post method when it opens. Can anyone help me. I am getting 'Uncaught syntax error. Unexpected token }' function Ma
Solution 1:
After knowing that you don't realy wanted a post.
<html><head><scripttype='text/javascript'src='http://code.jquery.com/jquery-1.8.3.js'></script><scripttype='text/javascript'>
$(function(){
MapIt = function() {
ListIds = '1234';//selected_Listings.join();if (navigator.appName == "Microsoft Internet Explorer") {
var opts = "screenX=0,screenY=0,width=" + screen.width + ",height=" + screen.height;
} else {
var opts = "outerWidth=" + screen.availWidth + ",outerHeight=" + screen.availHeight + ",screenX=0,screenY=0";
}
$('#myHidden').val(ListIds);
window.open('opener.html','Map', opts+',toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no');
}
});
</script></head><body><buttonid="run"onclick="MapIt()">run</button><inputtype="hidden"id="myHidden"></body></html>
An then in your opener.html
<html><head><scripttype='text/javascript'src='http://code.jquery.com/jquery-1.8.3.js'></script><scripttype='text/javascript'>
$(function(){
var listIds = window.opener.document.getElementById('myHidden').value;
$('#valuesRead').text(listIds);
});
</script></head><body><spanid="valuesRead"></span></body></html>
BEWARE This has in some browsers (Chrome for one) security objections if you run it locally
Solution 2:
Actually... your syntax is wrong in the form It should look like this
$('<form action="'+urlStr+' target="submission" onsubmit="window.open(\'http://www.google.com\',\'Map\',\''+opts+',toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no\');return true;" method="post"><input type="hidden" value="'+ListIds+'"></form>').submit();
You have to escape the " inside the string... oh and a coma is missing after the opts...
<html><head><scripttype='text/javascript'src='http://code.jquery.com/jquery-1.8.3.js'></script><scripttype='text/javascript'>
$(function(){
MapIt = function() {
ListIds = '1234';//selected_Listings.join();if (navigator.appName == "Microsoft Internet Explorer") {
var opts = "screenX=0,screenY=0,width=" + screen.width + ",height=" + screen.height;
} else {
var opts = "outerWidth=" + screen.availWidth + ",outerHeight=" + screen.availHeight + ",screenX=0,screenY=0";
}
var urlStr = "http://wwwd.dev.theabc.com/bingmaps/Map";
$('<form action="'+urlStr+' target="submission" onsubmit="window.open(\'http://www.google.com\',\'Map\',\''+opts+',toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no\');return true;" method="post"><input type="hidden" value="'+ListIds+'"></form>').submit();
}
});
</script></head><body><buttonid="run"onclick="MapIt()">run</button></body></html>
Post a Comment for "Performing A Post In Window.open()"