我有一個隱藏字段,我試圖抓取用戶屏幕分辨率。然後在處理結束通過php檢索屏幕分辨率。不幸的是,我對javascript的理解非常有限。這是我的。我真的很感激任何幫助。從窗體中檢索javascript輸出通過php
<head>
<script type="text/javascript">
function xy(){
document.write(screen.width + "x" + screen.height);
document.getElementById('xy').value;
}
</script>
</head>
<form action="" method=post >
//other fields here
<input type="hidden" name="xy" id="xy" value=""/>
<input type=submit name="button" value="button" />
</form>
當我查看頁面的源代碼時,是否應該看不到設置爲例如「1366x768」的值?現在在處理方面,我想用這樣的php提取信息。
if(isset($_POST['xy']) && (!empty($_POST['xy'])){
$blah = $_POST['xy'];
//sanatize $blah;
}
感謝您的回覆,onsubmit應該做的onclick一樣,對吧? – ulliw 2012-04-21 17:43:36
@ulliw這將帶你不到一分鐘的時間來測試; - - ) – kba 2012-04-21 17:46:16