Is there a way to check if JavaScript is enabled with PHP? If so, how?
PHP can't be used to detect whether javascript is enabled or not. Instead use <noscript> to display an alternate message / do something. Browsers don't load separate JavaScript-files if JavaScript is disabled.
Google Chrome In the "Settings" section click on the "Show advanced settings..." Under the the "Privacy" click on the "Content settings...". When the dialog window opens, look for the "JavaScript" section and select "Allow all sites to run JavaScript (recommended)". Click on the "OK" button to close it.
To detect if JavaScript is disabled in a web browser, use the <noscript> tag. The HTML <noscript> tag is used to handle the browsers, which do recognize <script> tag but do not support scripting. This tag is used to display an alternate text message.
JavaScript is used as client side to check and verify client details and PHP is server side used to interact with database. In PHP, HTML is used as a string in the code. In order to render it to the browser, we produce JavaScript code as a string in the PHP code.
perhaps a more simple option...
<html> <head> <noscript> This page needs JavaScript activated to work. <style>div { display:none; }</style> </noscript> </head> <body> <div> my content </div> </body> </html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With