Solved

Various Browser checks

Posted on 2007-04-02
6
249 Views
Last Modified: 2008-02-01
Hi, Thanks for looking at my question, any idea's/comments are appreciated.

I am developing a login page to an online application and I would like to check the following information on the clients browser:

1. They must be using  i.e. 6 or up?
2. Cookies must be enabled (as I'm using sessions)
3. Javascript must be enabled

4. Also, I'm not sure if this is even possible but, is there a way of checking to see if the user's browser has the Check for newer version of stored pages' set to 'Every visit to the page''

If any of the above checks come back as false I would like to DISABLE my Username and password inputs.

Most of the applications I have developed have all been in-house so I've not had to worry which browser version etc as they have all been the same so this is a little different for me!  

Are there any other standard checks that I have missed out that i should be doing?

Many thanks for your time.

PDM
0
Comment
Question by:Pigdogmonster
[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
  • 5
6 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 18835526
1:
agt = navigator.appVersion.toLowerCase();
var iePos     = agt.indexOf("msie");
var is_ie     = ((iePos !=-1) && (agt.indexOf("opera") == -1));
if (is_ie) {
  is_minor = agt.substring(iePos+5,agt.indexOf(';',iePos))
  is_major = parseInt(is_minor)
}
var is_ie6up  = (is_ie && (is_major >= 6));

alert(is_minor+'\n'+is_major+
'\n'+is_ie6up)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 18835542
2:

// cookie.js file
/* (c) 1999-2007 Michel Plungjan javascripts(at)planet.nl
   unless otherwise stated */
   
today      = new Date();
expiryDate = new Date(today.getTime() + (365 * 86400000));

function isCookieEnabled() {
   if (document.all) return navigator.cookieEnabled;
   setCookie('testcookie',today.getTime());
   var tc = getCookie('testcookie');
   delCookie('testcookie');
   return (tc == today.getTime());
}


/* Cookie functions originally by Bill Dortsch */

function setCookie (name,value,expires,path,theDomain,secure) {
   value = escape(value);
   var theCookie = name + "=" + value +
   ((expires)    ? "; expires=" + expires.toGMTString() : "") +
   ((path)       ? "; path="    + path   : "") +
   ((theDomain)  ? "; domain="  + theDomain : "") +
   ((secure)     ? "; secure"            : "");
   document.cookie = theCookie;
}

function getCookie(Name) {
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      var offset = document.cookie.indexOf(search)
      if (offset != -1) { // if cookie exists
         offset += search.length
         // set index of beginning of value
         var end = document.cookie.indexOf(";", offset)
         // set index of end of cookie value
         if (end == -1) end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      }
   }
}
function delCookie(name,path,domain) {
   if (getCookie(name)) document.cookie = name + "=" +
      ((path)   ? ";path="   + path   : "") +
      ((domain) ? ";domain=" + domain : "") +
      ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 18835575
1,2,3:

<script src="cookie.js"></script>
<script>
agt = navigator.appVersion.toLowerCase();
var iePos     = agt.indexOf("msie");
var is_ie     = ((iePos !=-1) && (agt.indexOf("opera") == -1));
if (is_ie) {
  is_minor = agt.substring(iePos+5,agt.indexOf(';',iePos))
  is_major = parseInt(is_minor)
}
var is_ie6up  = (is_ie && (is_major >= 6));

if (!is_ie6up) {
  document.write('Please use IE6+');
}  
else if (!isCookieEnabled()) {
  document.write('Please enable cookies');
}
else document.write('<input type="text" name="userid" value=""><br><input type="password" name="password" value="">');
</script>
<noscript>
Please enable javascript
</noscript>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 18835584
4 cannot be detected but you can expire the page using meta tags or server settings

PS: 50 points?
0
 

Author Comment

by:Pigdogmonster
ID: 18835808
Hi Mplungan, thank you.

Is there a way I can make the elements in my form disabled, something like..


  document.FORMNAME.username.disabled = true;
  document.FORMNAME.password.disabled = true;
  document.FORMNAME.button.disabled = true;
}
</script>
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 50 total points
ID: 18835883
Sure.... But my solution will not even show them :)


<script src="cookie.js"></script>
<script>
agt = navigator.appVersion.toLowerCase();
var iePos     = agt.indexOf("msie");
var is_ie     = ((iePos !=-1) && (agt.indexOf("opera") == -1));
if (is_ie) {
  is_minor = agt.substring(iePos+5,agt.indexOf(';',iePos))
  is_major = parseInt(is_minor)
}
var is_ie6up  = (is_ie && (is_major >= 6));

function initPage() {
  if (!is_ie6up || !isCookieEnabled()) {
    document.FORMNAME.username.disabled = true;
    document.FORMNAME.password.disabled = true;
    document.FORMNAME.button.disabled = true;
  }
}
window.onload=initPage;
</script>


Michel
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Suggested Solutions

Title # Comments Views Activity
Link Anchor Not working 9 67
Where is this content coming from? 4 40
jQuery element reference issue 2 38
Javascript not to let an input enter more or less 4 15
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

738 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