Solved

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

Posted on 2009-07-02
6
156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

749 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