set a variable without clicking or posting
I'm trying use this as a 404.shtml error page:
- <script src="http://code.jquery.com/jquery-latest.js"></script>
- <script language="javascript" type="text/javascript">
- var viewportwidth;
- var viewportheight;
- /* the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight */
- if (typeof window.innerWidth != 'undefined'){
- viewportwidth = window.innerWidth,
- viewportheight = window.innerHeight
- } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){
- viewportwidth = document.documentElement.clientWidth,
- viewportheight = document.documentElement.clientHeight
- } else {
- viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
- viewportheight = document.getElementsByTagName('body')[0].clientHeight
- }
- $.post('404.php', { js: "viewportwidth"});
- </script>
and have this code in the 404.php page
- <?php
- session_start(); //start PHP Session
- $_SESSION['jsvalue'] = $_POST['js']; //store the posted value in a php session variable
- ?>
- This is a PHP Page. The javascript value is: <?php echo $_SESSION['jsvalue']; ?
How can I get it to call the php page without clicking or posting anything...
If I add after above code, th
e virtual include "
<!--#include file="
404.php
" -->" to the shml file so it doesn't mess with the request uri there is no var set.
I have tried a bunch of other jquery functions trying to get to work... I'm not a js, jquery or ajax wizard so please hold my hand...
Thanks in advance... I'm running out of hair... lol