Redirecting to another page if javascript is disabled

Posted on 2009-05-16
Last Modified: 2012-06-21
Hi Experts,
I want to include a logic in my index.php page that if the Javascript is disabled on the users system, it shoud automatically redirect the users to another page.
Only if the javascript is enabled shoudl the user be able to access that page.

Also, is it possible to automatically enable javascript on the users browser when they try to access my index.php page?

Please help
Question by:sandhya01
  • 3
  • 2

Accepted Solution

pedro_sland earned 250 total points
ID: 24402470
A html page cannot force a user to use javascript. It would be better to design a page so that users without javascript can use it as well as users with. If this is really necessary then use something like this in your <head>:

  <meta http-equiv="refresh" content="0;URL=">

Open in new window


Author Comment

ID: 24406992
Hi pedro_sland,
It is fine to use meta http refresh, in your html page?
Please let me know.


Expert Comment

ID: 24439603
Its not very good but I think its the only way to do what you ask.

I recommend this method though. Progressive Enhancement with Javascript is a good article to explain what I mean by a page for users with and without javascript. If you need help with replacing inline event handlers and browsers difficulties, try the Prototype library or jQuery. I use jQuery for my js. There are also a great list of plugins to do almost everything you could want!

If you wanted to redirect someone who does have javascript to another page, then use something like:
<script type="text/javascript">
  window.location.href = '';
If you wanted to show a message asking a user to enable javascript to get the most from your site:
  <p>Please enable Javascript in your browser to get the best from this site. <a href="why_use_javascript.php">What Javascript will give me</a></p>

Open in new window


Author Comment

ID: 24493376
Hi Expert,
Actually I want to implement login mechanism using javascript, So that I should only allow the login page to be visible, if the users have JS turned on. else they should be redirected to another page which has instructions on how to enable JS.

Am I following the right approach.



Expert Comment

ID: 24501482
You would be better to use javascript to show the login form (use css to hide it and javascript to show it on page load). If they do not have javascript enabled, show a message instead by surrounding it in <noscript></noscript>. noscript tags are hidden if javascript is enabled.

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Obtaining data on ASP 8 28
Use Images instead of radio button and get the checked value and pass it to a h2 tag 3 17
Link failure 16 32
$_SERVER Variable question 31 26
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

840 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