[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

need to check if user has javascript enabled and display a error msg.

Posted on 2004-10-25
10
Medium Priority
?
251 Views
Last Modified: 2012-05-05
I need a php script that checks to see if they have javascript enabled and if not displays a error page.
Have tried to make this a few times and can't make it work.

Much Thanks..
Caiapfas
0
Comment
Question by:Caiapfas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +1
10 Comments
 
LVL 21

Expert Comment

by:MogalManic
ID: 12406304
Try this:  (It should work for IE 4.0 and above and Netscape 4.x)

<script LANGUAGE="JavaScript">
     <!-- document.write("Hello World.") -->
</script>
<noscript>
     <b>Please>/b> try this page for browsers that can not handle SCRIPTing.
     <a HREF="http://www.foo.com/alternate.html">Simple Text Page</a>
</noscript>

0
 
LVL 2

Author Comment

by:Caiapfas
ID: 12407008
I need it to be php :Reason so i can redirect them to a page telling them how to enable it.. or a page that doesnt need js
0
 
LVL 6

Expert Comment

by:cwkhang
ID: 12408903
u want to redirect

<SCRIPT LANGUAGE="JavaScript">
if (!navigator.javaEnabled())                   //if javascript is not enabled, then redirect to nojava.html
{
           document.location = "nojava.html";
}
</SCRIPT>
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Expert Comment

by:cwkhang
ID: 12408932
ops... i see you want to test javascript
the code above is to test java
sory bout tat

as javascript is disable, surely u can't use javascript to test or to do the redirect
0
 
LVL 6

Expert Comment

by:cwkhang
ID: 12408984
umm, how about try to do this way

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
window.location="http://www.abc.com/javascript-page.html";  //if javascript is enabled, redirect to page that need js
// End -->
</script>
          <!--else just telling them how to enable it over here or put ur no-java page here-->
<noscript>
It appears that your browser does not support JavaScript, or you have it disabled.  This site is best viewed with JavaScript enabled.<p>If JavaScript is disabled in your browser, please turn it back on then reload this page.<p>Or, if your browser does not support JavaScript,
click <a href="http://www.your-web-site-address-here.com/no-javascript-page.html">here</a>.
</noscript>
0
 
LVL 2

Author Comment

by:Caiapfas
ID: 12415230
I'd perfer a php way to do this...for the automatic redirect...plus page blank out
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 12415290
Just replace your PHP page for the .html files in our samples
0
 
LVL 2

Author Comment

by:Caiapfas
ID: 12424173
yes, i am aware that i can change the link..

but i want a php script that actual does the check and stops the page from being displayed and then redirects...
I can't add a javaascript check page in the sequence of pages that loads....
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 12442632
The PHP server cannot obtain that kind of information about the clients browser.  You could design a page that sends to the server a parameter that says that javascript is enabled or not enabled.  Then the PHP can store that value in a session variable.  Later pages can then act on the results of that variable.

EG.
  Login.PHP - sends javascript 'enabled' as 1 or 0 when user clicks login (It also sends username/password)
  AuthenticateUser.PHP - Stores 'enabled' in session
  ProcessOrder.PHP - Does more vigorious validation if 'enabled' is 0
0
 

Accepted Solution

by:
grinchy earned 1000 total points
ID: 12485288
This will do what you want almost completely transparently

<html>
<head>
<?
if($_GET['check']!='ok')
{
?>

<script>
window.location='?check=ok'
</script>


</head>
<body>
PAGE FOR NONE JS USERS


<?
}

else
{
?>

</head>
<body>
PAGE FOR JS USERS

<?
}
?>

</body>
</html>
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Starting up a Project

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question