Solved

how to use redirect funtion of php if javascript is disabled.

Posted on 2009-05-07
2
220 Views
Last Modified: 2012-06-21
Hello, i want to redirect page if javascript is turn off but i am not getting idea .how ? i did this but not working...
<noscript>
<?php
redirect('jsdisabled.php');
?>
</noscript
<body>
<noscript>
<?php
redirect('jsdisabled.php');
?>
</noscript>
</body>

Open in new window

0
Comment
Question by:san4u49
[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
2 Comments
 
LVL 1

Accepted Solution

by:
Patrick_NG earned 20 total points
ID: 24323405
Quite a common problem, one which can't be solved by PHP, as the redirect command works by modifying the header - and you can't modify the header any more after you wrote a single line of HTML output (such as <body> and <noscript> in your example).

You need to be a little tricky for automatic redirects - the issue and a workaround is very well described over at http://www.rocket99.com/jscript/jsdetect.html. The core part of it is attached to this post.
<HTML> 
<HEAD> 
  <SCRIPT LANGUAGE="JavaScript"> 
  <!-- 
      window.location = "jsenabled.php" 
  //-->
  </SCRIPT> 
  <META HTTP-EQUIV="REFRESH" CONTENT="1; URL=/jsdisabled.php"> 
</HEAD>
 
<BODY> 
   <A HREF=/jsdisabled.php><IMG SRC=images/giantcoLogo.gif HEIGHT=60 WIDTH=120 BORDER=0 ALT="GiantCo Home Page"></A> 
</BODY> 
</HTML> 

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

739 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