Solved

javascript

Posted on 2008-10-03
10
1,237 Views
Last Modified: 2013-12-08
Is there any way using javascript i can detect the browser settings like tools/internet options-- settings/check for newer version of stored pages---every visit to the page,never etc.
I have an apllication which does not allow the user to login with some of these settings set .How can i check there settings and code in a way which allows then to login the application?
0
Comment
Question by:akohli
  • 4
  • 4
10 Comments
 
LVL 19

Expert Comment

by:LordOfPorts
ID: 22638299
There is a Navigator object http://www.javascriptkit.com/jsref/navigator.shtml that provides some browser related information however Javascript does not have the ability to read a user's settings from the "Internet Options".
0
 
LVL 6

Expert Comment

by:ysfx
ID: 22639236
Another common practice is to test to see if a similar functionality fails. For example, store a cookie value then pull the value again. If the value is the same, cookie is enabled else disabled.
0
 

Author Comment

by:akohli
ID: 22641696
Can i get a code example or if there is any other way(other than javascript) to fetch the user settings of internet options?
0
 
LVL 19

Expert Comment

by:LordOfPorts
ID: 22641907
The code snippet below has an example of using the Navigator object to read the available browser information, reading and setting cookies, and using the <noscript> HTML tag that is accessed when the user does not have JavaScript enabled.

Short of installing a custom written, e.g. in Java, C++, etc., plug-in on the user's browser (with a user's explicit permission) there is no way to detect the settings from "Internet Options" as they are stored in e.g. the registry, local files, etc. so accessing them through JavaScript would be a breach of security.

What you can do is first identify the cause of your application not working for some users, i.e. is JavaScript not enabled and therefore your application does not work in which case you would use the <noscript> tag to inform the user that your application requires JavaScript in order to function properly; does the application require a specific browser in which case try using the navigator object to identify which browser the user has.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>Detecting Browser/Setting Cookie</title>

</head>

<body>
 

<!-- The noscript tag will be accessed if the browser does not support JavaScript -->

<noscript>

 <h2>JavaScript is not enabled.</h2>

</noscript>
 

<script type="text/javascript">

// Using the Navigator object
 

document.write("appCodeName: " + navigator.appCodeName + "<br />");

document.write("appName: " + navigator.appName + "<br />");

document.write("appVersion: " + navigator.appVersion + "<br />");

document.write("cookieEnabled: " + navigator.cookieEnabled + "<br />");

document.write("userAgent: " + navigator.userAgent + "<br />");

document.write("Supported MIME Types<br />");

for(var i = 0; i < navigator.mimeTypes.length; i++) {

    document.write("&nbsp;" + navigator.mimeTypes[i].type + "<br />");

}
 

</script>
 

<script type="text/javascript">

// Using cookies
 

if(!document.cookie) {

    // No cookie has been set yet

    alert('No cookie has been detected');

    

    // Set the cookie for 3 days

    var dtDate = new Date();

    dtDate.setTime(dtDate.getTime() + (3 * 24 * 60 * 60 * 1000));

    var sExpirationDate = "expires=" + dtDate.toGMTString();
 

    document.cookie = "user:name;" + sExpirationDate;

}

else {

    // Found cookie, show value

    alert(document.cookie);

}
 

</script>
 

</body>

</html>

Open in new window

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:akohli
ID: 22642216
thanks for the reply...i know the user is facing the problem because he does not  have any particular "check for newer versions of web page"" option clicked,but is there any (without using javascript) other way using which we can come to know about user's Internet options (this particular settings)
0
 
LVL 19

Accepted Solution

by:
LordOfPorts earned 250 total points
ID: 22642298
Regarding the internet options, the only way you could gain access to them is to write a browser plug-in that will communicate with your web application and a user must explicity install. This would be a pretty complex task, e.g. here are few articles on the topic:

IE
http://msdn.microsoft.com/en-gb/library/bb250489(VS.85).aspx
http://www.codeproject.com/KB/cs/Attach_BHO_with_C_.aspx

Firefox
http://www.ibm.com/developerworks/web/library/wa-xul1/

In this case it appears that caching is the problem so you could try to disable caching of your web pages, the following article shows how you could try to disable caching of web pages so the browser will check for newer version of your web page each time:

http://support.microsoft.com/kb/234067
http://www.mnot.net/cache_docs/

One very basic, albeit not absolutely reliable, example is placing the following META tags in the HEAD section of the web page:
<meta http-equiv="Pragma" content="no-cache" />

<meta http-equiv="Expires" content="-1" />

Open in new window

0
 

Author Comment

by:akohli
ID: 22651019
Thans again for the reply...i am little confused...seeing the articles it says its better to use http header than meta tags,where and how should i write the http header.Like u sent the two lines for meta,can u also send the code that is to be written for http header.In the article it says http header is generated by the server,if so then where and how should i make the settings for not caching the page...
0
 

Author Comment

by:akohli
ID: 22651035
i am using websphere...
0
 
LVL 19

Expert Comment

by:LordOfPorts
ID: 22651680
How to set the http header server-side depends on the scripting language you are using and while I am not familiar with websphere this EE thread appears to have the exact steps http://www.experts-exchange.com/Software/Internet_Email/Web_Browsers/Q_21423506.html
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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

758 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

21 Experts available now in Live!

Get 1:1 Help Now