Solved

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

Posted on 2009-05-07
2
213 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Fulfillment API php code sample 1 56
PHP Query return divisible by 3 3 25
How to call a web service and get the results posted in a form in PHP 9 51
Ajax and PHP 9 29
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 count occurrences of each item in an array.

791 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