Solved

Looking for reusable Javascript & Cookie support add-in for webpage

Posted on 2009-07-02
6
153 Views
Last Modified: 2012-05-07
I am looking for a simple piece of client side code that can be included in my webpages that runs onload to detect whether the user has javascript and cookies enabled, and then sends them to a page that explains how to enable these items based on their browser type and version if either is not. I am sure that I could write this myself, but it seems that there must already be "library" item that I could use to include in my websites that would be more comprehensive than I could create.
0
Comment
Question by:Rich
  • 2
  • 2
  • 2
6 Comments
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
to check for javascript you can use the  tag
to chek if cookies are enabled, you need to force the browser to send a request after your application has set a cookie, this is usually done with a meta redirect or using webbugs (1-pixel images)
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
Comment Utility
Here


<script type="text/javascript" src="cookie_utils.js"></script>

<script type="text/javascript">

if (!isCookieEnabled()) location.replace('explaincookies.html')

</script>

<noscript>

It seems you have turned javascript off. Please read <a href="jsexplain.html">here</a> what you are missing out on

</script>

Open in new window

cookie-utils.js.txt
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
just a pedantic note:
you cannot reliably test for cookie functionality with javascript, as a browser may disallow settings cookies with scripting; for example mozila with
  user_pref("dom.disable_cookie_set", true);
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Rich
Comment Utility
mplungian,

That is part of what I am looking for, and in rereading my question, maybe not obvious, but mostly looking for the content of explaincoolies.html and jsexplaine.html that will check for users current browser and then provide the specific instructions for enabling cookies and/or javascript. Anything you know of that includes that functionality?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
0
 

Author Closing Comment

by:Rich
Comment Utility
OK, thanks. I will use the code and try to come up with the instruction part myself. Maybe keeping in generic will suffice for now. I am just suprised that there isn't some prepackaged source for this pretty standard need.
0

Featured Post

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

Join & Write a Comment

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to count occurrences of each item in an array.

743 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