用PHP程式來顯示瀏覽者的顯示器解析度

來源:互聯網
上載者:User
程式|解析度|顯示   本教程屬於原創,轉載請註明網頁教學網

  今天給大家做出了一個能顯示瀏覽者的螢幕解析度的PHP代碼,希望大家使用 一下,有什麼問題請到論壇發帖討論。

  首先建立一個檔案取名為:resolution.php代碼的內容如下:(注意:檔案的副檔名必須是.PHP不要是.HTML)

<script language="javascript">
<!--
function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_res="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie

location = '';
}

function checkRes(width, height) {
if(width != screen.width || height != screen.height) {
writeCookie();
} else {
return true;
}
}
//-->
</script>


<script language="javascript">
<!--
checkRes(1024, 768);
//-->
</script>



//網頁教學網http://www.webjx.com 網頁設計師的搖籃!!

  其次把下面的代碼放到你想在哪顯示訪客的顯示器解析度資訊的地方就可以了!( 下面代碼當然也是放在副檔名為.PHP的檔案中)

<?php 
$callget_res_page_name = $REQUEST_URI;
$GLOBALS[callget_res_page_name ] = $callget_res_page_name;
include("resolution.php");
echo $screen_width."x".$screen_height." is your screen resolution.";
?>

  注意:$應該是半形。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.