hi all, i want to using navigator.appVersion to get user's os , and return the value to php in order to save the value to db , so how to call navigator.appVersion from php , and return the value to php ??
Doesn't PHP have its own function to do this task, i.e: get_browser()? But if you prefer javascript's navigator.Appversion, then perhaps you have to write a javascript function which reports back to server using Ajax technique. The Ajax should call PHP to save navigator.Appversion result into DB
This is php code! $browser = get_browser(null, true); echo $browser['browser']." ".$browser['version']; Code (php): Should echo "Yourbrowsersname version", eg "Firefox 5.0"
There are different scripts. Php is working on server side generating web page html-code (including javascript references in it). Then web page lives it's own life and javascript is working on client side where php means nothing. The only thing you can do is insert js calling in "onload" attribute of <body>.
this is heavily counts on your browsercap.ini you set! many times it wont work, and once agian, search for: PHP BrowserCap @ SourceForge it should find it, a great solution! also, as jek8519 said, PHP is a server-side lang, which means the code renders at the server then returns the HTML-CSS-JS to your browser to render! you can always use a <a> tag fot executing js eg <a href="javascript:myfunc();" >blab</a> Code (markup):
something like (at the top of your page): <script type="text/javascript"> window.location.href = window.location.href + "?browser=" + navigator.appVersion; </script> Code (markup): This will reload the page, with the browser in the querystring. You can then access this easily from php. An alternative is to use ajax or even an iframe or image to save the data: <img id="savebrowser" style="display: none" /> <script type="text/javascript"> document.getElementById("savebrowser").src = "savebrowser.php?browser=" + navigator.appVersion; </script> Code (markup):