Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-07-02
6
Medium Priority
?
159 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 2000 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
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 …
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…
Suggested Courses

618 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