หาความกว้างของหน้าจอด้วย php javascripts (resolution)


หน้าแรก PHP MySQL เกร็ดความรู้ หาความกว้างของหน้าจอด้วย php javascripts (resolution)

หาความกว้างด้วย javascript





  Code
<script LANGUAGE="javascript">
width = screen.width;
height = screen.height;
document.write("<b>You're set to "+width+ "X" +height+"</b>")
</script>



หาความกว้างด้วย javascript แล้วแปลงลงมาใส่ php





  Code
<?
if(!isset($_GET['r']))
{
echo "<script language="JavaScript">
<!--
document.location="".$PHP_SELF."?r=1&width="+screen.width+"&Height="+screen.height;
//-->
</script>";
}
else {

// Code to be displayed if resolutoin is detected
if(isset($_GET['width']) && isset($_GET['Height'])) {
// Resolution detected
echo $_GET['width'];
}
else {
echo "no";// Resolution not detected
}
}

?>



ขึ้นไปด้านบน