Solved

programmatically detecting javascript enabled

Posted on 2010-11-08
7
379 Views
Last Modified: 2012-05-10
Hi,

I need a way of detecting in my code behind if possible if javascript has been enabled or disabled.

There seem to be lots of examples of detecting if a browser is capable but I need to know if it is actually switched in or out.

Any ideas?
0
Comment
Question by:scm0sml
  • 4
  • 2
7 Comments
 
LVL 13

Assisted Solution

by:F Igor
F Igor earned 150 total points
Comment Utility
There is no difference between javascript when it's not enabled and when it's not supported. You can use the <NOSCRIPT> </NOSCRIPT> tags to put some code, message, or alert to the user that it's not enabled/supported.

I'm not sure if exists some browser specific function to detect this feature,
because whatever function existent would require some type of script enabled.

0
 
LVL 7

Expert Comment

by:dxdinh
Comment Utility


try to use the noscript with with message or redirection when script disable

more on this.

http://www.plus2net.com/javascript_tutorial/javascript_support.php
0
 

Author Comment

by:scm0sml
Comment Utility
is there way of automatically redirecting within <noscript>?

I don't want the user to be aware of what is going on so if javascript is disabled then they automatically get redirected to another page......?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 7

Expert Comment

by:dxdinh
Comment Utility
this line will redirect to your page how enable the script within 2 second

  <meta http-equiv="refresh" content="2; URL=RedirectPageHere.html">

-------------------------
http://www.plus2net.com/javascript_tutorial/javascript_support.php
0
 
LVL 7

Accepted Solution

by:
dxdinh earned 350 total points
Comment Utility
or to simplify the code within 1 second redirect

<noscript>

<meta http-equiv="refresh" content="1; URL=RedirectPageHere.html">

</noscript>

0
 

Author Comment

by:scm0sml
Comment Utility
mmmm the re-direct works fine.

I was hopinh to redirect to the same page but passing in a param js=off.

The problem is it gets stuck in an infinite loop.....
0
 
LVL 7

Expert Comment

by:dxdinh
Comment Utility
you can not redirect to the same page since <noscript> will be in the head section and the browser will execute first

 what you can do is setting up a landing page such as env.html from this page depend on the javascript enable or not you will redirect them to the right page or add the right parameter to pass onto redirect page

 let's say you have default.html as of right now
 
 so from default.html
 <noscript> redirect to home.html?js=off</script>
  <script>
     yes
         redirect home.html?js=on

</script>
       
 

 
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now