I am getting a screen resolution through XMLHttpRequest. I am opening a show_content.php file with xmlhttp.open that contains screen resolution variables which I pull with the GET Method.
xmlhttp.open("GET","show_content.php"+queryString,true);
This works!
and showing this file with the variables in a following div
<div id="txtResolution"></div>
This part works as well!
PROBLEM: This div ( show_content.php ) contains screen resolution variables that I would like to use throught the rest of the code outside of it but I can not pass them somehow. How can I get those variables to be passed to the original code.
I used the GET method but can not pass the variables to the original code outside the show_content.php I have tried with GLOBALS and Sessions as well but no luck
Here ist the code. Everything works properly but I can not pass the variables from the "txtResolution" div to the rest of the code
function showResolution(field_id)
{
var xmlhttp;
if (field_id.length==0)
{
document.getElementById("txtResolution").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtResolution").innerHTML=xmlhttp.responseText;
}
}
var winW = 630, winH = 460;
if (document.body && document.body.offsetWidth) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetWidth ) {
winW = document.documentElement.offsetWidth;
winH = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
winW = window.innerWidth;
winH = window.innerHeight;
}
var queryString = "?width=" + winW + "&height=" + winH;
xmlhttp.open("GET","show_content.php"+queryString,true);
xmlhttp.send();
}