Solved

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

Posted on 2009-07-02
6
154 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
ID: 24771858
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
ID: 24772219
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
ID: 24772304
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Rich
ID: 24772629
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
ID: 24772881
0
 

Author Closing Comment

by:Rich
ID: 31599366
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PowerShell Get-Help 10 77
powershell script help 5 79
Batch command to determine the Office version installed 2 134
Using a variable to name output in powershell script 2 38
Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

777 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