 |
 |
IE 5 specific version detect
|
 |
|
 |
|
Addicted to MacNN
Join Date: Sep 2000
Status:
Offline
|
|
I want to detect a specific version of Internet Explorer: 5.1 for Mac only. Does anyone have a good JS that would work to detect that specific version, not IE 5 in general, or IE 5 cross platform.
|
I always use protection when fscking my Mac... Do you?
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Status:
Offline
|
|
Basically what you need to do is to get the browser's USER_AGENT property. You then need to parse the string and search for "MSIE" which will indicate that it's a Microsoft Browser. You'd also need to look for the version and machine string (i.e. "Macintosh" or "PowerPC"). Here's a link for ASP developers but since VBSCript is almost English, you'll be able to understand it and turn it into client-side javascript (if that's where you want to detect it).
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnproweb/html/summaryofbrowserdetectiontechniques.asp" target="_blank">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnproweb/html/summaryofbrowserdetectiontechniques.asp</a>
Talks about:
"The navigator object, a sub-object of the main top-level window object, provides the three useful properties userAgent, appName and appVersion. The userAgent property contains the string that completely identifies the browser, and is sent to the server in the HTTP headers with each page request it makes. The appName and appVersion properties are available only in client-side script, and contain the manufacturer's name and the browser version in a more readable format."
-Raman
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
Here's a handy Javascript for you:
var browser = new checkBrowser();
function checkBrowser() {
this.browser = navigator.userAgent.toLowerCase();
this.version = navigator.appVersion.toLowerCase();
this.mac = this.version.indexOf("mac")!= -1 ? 1 : 0;
this.ns = (this.browser.indexOf("mozilla")!=-1&&this.browser.indexOf("compatible")==-1&&document.layers) ? 1 : 0;
this.ie = (document.all) ? 1 : 0;
this.dom = (document.getElementById) ? 1 : 0;
this.domie = (this.dom&&this.ie) ? 1 : 0;
this.domns = (this.dom&&!this.ie) ? 1 : 0;
this.min = (this.ns||(this.ie&&(t his.mac&&this.version.indexOf("msie 4")!=-1))||this.dom);
return this;
}
In most cases (damn nearly all!) it will properly determine which kind of browser DOM you are using, and any extra information that is necessary (like Mac compatibility).
It also has a browser.min property which you can use to test for proper DHTML functioning (it does not provide for IE4 or 4.5 for Mac which was pretty hopeless anyway). It also makes a distinction between the new DOM of IE5/6 and NS/Mozilla 6+ which can vary ever-so-slightly in implementation.
This script is a collection of hints and tips I've seen on places like <a href="http://www.dynamicdrive.com" target="_blank">http://www.dynamicdrive.com</a> and <a href="http://www.hotscripts.com" target="_blank">http://www.hotscripts.com</a> so use it to your heart's content.
<small>[ 07-04-2002, 09:14 PM: Message edited by: Simon Mundy ]</small>
|
|
Computer thez nohhh...
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Sep 2000
Status:
Offline
|
|
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"><SCRIPT LANGUAGE="JavaScript">
<!--
document.write(navigator.userAgent)
//-->
</SCRIPT></pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Provides "Mozilla/4.0 (compatible; MSIE 5.14; Mac_PowerPC)" which is good...
But does anyone know of a foolproof way to get the version number "5.14" isolated? Even in cases such a "5.1" or whatever else they may do in the future "5.2.1" or "6"... I need to get just the version number, regardless of how long or short it is.
|
I always use protection when fscking my Mac... Do you?
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |