avoid form warning if user clicks refresh (ok)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="vietnamese">
<meta property="og:locale" content="vi_VN">
<meta name="google-site-verification" content="PuA4RXn1IGZbiglCjRvzLUPAKPYw6amIu79SJHmavlQ">
<meta name="theme-color" content="#13b5ea">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="language" content="vn">
<meta name="keywords" content="học trực tuyến, học online">
<title>*Client Info*</title>
<style>table,tr{border:2px solid gold;border-collapse:collapse;}td{padding:5px;}</style>
</head>
<body>
<?php
$clientProps=array('screen.width','screen.height');
if(! isset($_POST['screenheight'])){
echo "<form method='POST' id='data' style='display:none'>";
foreach($clientProps as $p) {
echo "<input type='text' id='".str_replace('.','',$p)."' name='".str_replace('.','',$p)."'>";
}
echo "<input type='submit'></form>";
echo "<script>";
foreach($clientProps as $p) {
echo "document.getElementById('" . str_replace('.','',$p) . "').value = $p;";
}
echo "document.forms.namedItem('data').submit();";
echo "</script>";
}else{
echo "<table>";
foreach($clientProps as $p) { //create output table
echo "<tr><td>".ucwords(str_replace('.',' ',$p)).":</td><td>".$_POST[str_replace('.','',$p)]."</td></tr>";
}
echo "</table>";
}
?>
<script>
window.history.replaceState(null,null); //avoid form warning if user clicks refresh
</script>
</body>
</html>
PreviousTự động submit bằng javscript :))) (ok)NextMột cách truy cập phần tử bằng js thông qua id lạ :)))
Last updated