Page 1 of 1
Enable Javascript Dynamically
Posted: Tue Nov 10, 2009 12:46 am
by romepatel
Hello,
I am new to PHP development,
I am using javascript in my PHP pages,
so i want to enable javascript dynamically by clicking a link in <noscript> <a >enable javascript</a></noscript> and refreshing the page by enabling the javascript.

Please can any help me out
Thanks in advance
Re: Enable Javascript Dynamically
Posted: Tue Nov 10, 2009 10:47 am
by ceiroa
I think the simplest way to do this would be to some PHP code at the top of the page that would read a GET parameter:
Code: Select all
$javascriptEnabled = $_GET['jvsEnabled'];
PHP would output the whole HTML page, but would only include the javascript if the link to enable it was clicked, and would include the link to enable javascript in the HTML:
Code: Select all
echo '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Title here</title>';
if($javascriptEnabled==true) {
echo "<script src="js/myJsCode.js" type="text/javascript"></script>";
}
echo '
</head>
<body>
<a href="thissamepage.php?jvsEnabled=true">Enable JavaScript</a>
...
</body>
</html>';
---------------
Carlos R. M. Eiroa
PHP Consultant
Re: Enable Javascript Dynamically
Posted: Tue Nov 10, 2009 10:57 am
by pickle
You cannot enable Javascript from a webpage. The best you can hope for is an instruction to the user to enable Javascript themselves.