Vote count:
0
My goal is to establish where a page was opened via a javascript pop up, and carry a related URTL varialble through to other page(s). Originally I thought I could do this with a URL variable however as java runs client side and php is server side there is no way to verify whether the window is a java windopw especially given the possibility that someone returned on a favorite or bookmark
I originally made a similar post to this however as the idea has evolved and being stuck with the variable in the URL, this may be a better approach
I think I have figured out the basics but the mechanics involve javascript that I am not so familiar with.
Here is what I have in a page right now
<script>
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
</script>
<a onclick="PopupCenter('/customconfig/index.php, 'CustomBuilder1',1080,700);" href="javascript:void(0);"> <img border=0 src = "/images/Animated.GIF"></a>
Now I found this page http://ift.tt/1rDC1Ed
which tells me how to pot a POST in a javascrip with this code
<script>
function postwith (to,p) {
var myForm = document.createElement("form");
myForm.method="post" ;
myForm.action = to ;
for (var k in p) {
var myInput = document.createElement("input") ;
myInput.setAttribute("name", k) ;
myInput.setAttribute("value", p[k]);
myForm.appendChild(myInput) ;
}
document.body.appendChild(myForm) ;
myForm.submit() ;
document.body.removeChild(myForm) ;
}
</script>
Of course the advantage of this method is that there is no URL variable when I go to the first page and I can also carry the POST value through all php pages.
My biggest question is how to merge the code for loading the centered javascript window with the code for passing the POST variable, and making them work "happy together"
This means that if someone goes back on a bookmark or favorite the POST value will be NULL, and I can carry that NULL value through the subsequent page(s) as a POST hidden value
Thanks,
Mark
Javascript POST to PHP page
Aucun commentaire:
Enregistrer un commentaire