如何检查客户端浏览器中是否启用了javascript?
问题描述:
正在用php创建网页.我想知道客户端浏览器中是启用还是禁用了JavaScript.
guyz,请您帮我解决这个问题.
am creating a webpage in php. i want to know whether javascript is enabled or disabled in client side browser.
guyz, will you please help me to solve this problem.
答
尝试以下方法:
http://techpatterns.com/downloads/javascript_browser_detection.php [ http://hungred.com/how-to/determine-whether -javascript-is-enabled-disabled-via-php/ [
Try these:
http://techpatterns.com/downloads/javascript_browser_detection.php[^]
http://hungred.com/how-to/determine-whether-javascript-is-enabled-disabled-via-php/[^]
hope it helps :)
您的问题似乎很明确,但实际上可能并非如此.原因如下:您想如何使用此功能?如果希望有一个JavaScript函数,如果在浏览器中禁用了JavaScript,则该函数返回false,请考虑一下:它永远不会被调用,因为……好吧,因为禁用了JavaScript. :-)它总是返回true或不被调用. :-)
而且,没有任何可靠的方法可以在服务器端使用PHP进行检查.这件事不是任何标准协议的一部分.例如,请参见: http://www.codingforums.com/showthread.php?t=138190 [ ^ ].
因此,您所能做的就是使用HTMLnoscript
, http://www.w3schools.com/tags/tag_noscript.asp [ ^ ].—SA
It looks like your question is very clear, but in fact it is probably not. Here is why: How you want to use this feature? If you hoped to have a JavaScript function which returns false if JavaScript is disabled in the browser, think about it: it will never be called because… well, because JavaScript is disabled. :-) It would always return true or not called. :-)
And there is no any reliable way to check it on server side with PHP. This matter is just not a part of any standard protocol. For example, see this: http://www.codingforums.com/showthread.php?t=138190[^].
So, all you can do is using HTMLnoscript
, http://www.w3schools.com/tags/tag_noscript.asp[^].—SA