Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if JavaScript is enabled with PHP

Tags:

javascript

php

Is there a way to check if JavaScript is enabled with PHP? If so, how?

like image 521
Will Avatar asked Dec 15 '10 20:12

Will


People also ask

How can I tell if JavaScript is enabled in PHP?

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.

Do I have JavaScript enabled?

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.

How do I know if JavaScript is disabled?

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.

Is JavaScript used in PHP?

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.


1 Answers

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> 
like image 176
Andrew Avatar answered Oct 02 '22 11:10

Andrew