Azu Posted May 2, 2007 Share Posted May 2, 2007 Can you please tell me how I can detect whether or not the client supports javascript? So that if it doesn't support it, I can have PHP do something? P.S. I need to know BEFORE headers from my server to the client, not afterwards. Quote Link to comment Share on other sites More sharing options...
mainewoods Posted May 5, 2007 Share Posted May 5, 2007 the noscript html tag will show whatever html is in it if there is no js or if js is turned off: <noscript>Please turn javascript on in your browser to use this web site</noscript> only runs when the page is parsed by the browser though. The only way the server can know whether the client has js on or not is by first loading a page into the client and then communicating it back to the server like through a meta refresh(yuck). Bottom line - no information about whether js is on or not is sent to the server in the headers in the request from the browser to the server! It ain't in there. Quote Link to comment Share on other sites More sharing options...
Azu Posted May 27, 2007 Author Share Posted May 27, 2007 Thanks ^^ the whole reason I am planning on using javascript though is to save bandwidth. I want to use external javascript to show my navigation menu, so it doesn't need to be downloaded over and over (which it should only do if javascript isn't supported) so I'd really appreciate it if there was some way to tell whether or not the client supports javascript. I guess I could include a javascript in every page that sends something to my server, and check on every page view if it was received or not, and store all the results in a mysql table, and then query the mysql every time a page is loaded to know whether or not javascript is supported, but this would put more load on the server, so I am looking for a way to quickly tell if it is on or off.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.