Reliable Javascript Version Detection?
Dec 24, 2003
I have been struggling around with trying to figure out a reliable manner for detecting the Javascript version a given browser is using.
Basically, there are two half-decent ways that I have found, neither one being foolproof.
One way is using javascript tags with the language attribute, as in the following code:
Code:
<SCRIPT LANGUAGE="Javascript"><!--
gVersion="1.0";
//-->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript1.1"><!--
gVersion="1.1";
//-->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript1.2"><!--
gVersion="1.2";
//-->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript1.3"><!--
gVersion="1.3";
//-->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript1.4"><!--
gVersion="1.4";
//-->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript1.5"><!--
gVersion="1.5";
//-->
</SCRIPT>
This works fine but it is not very elegant. Another disadvantage is that it is not XHTML compliant.
The other way is using some sniffer scripting like that found in the JavaScript Browser Sniffer (Web Reference).
However, this is not very reliable as it needs to be constantly updated to take newer browsers into consideration. Also, on my system it gave an incorrect Javasctipt version of 1.3 when it should have given 1.5 (according to the first option above).
I was just wondering if there was a more dependable way of doing this.
Maybe it would just be better to avoid unnecessary headaches and restrict myself to W3C compliant brwosers.
View 5 Replies
ADVERTISEMENT
Jul 23, 2005
I've have got this script, the only thing I want to be changed is the first part. It has to detect IE version 6 instead of just "Microsoft Internet Explorer". Can somebody help me out? I tried "Microsoft Internet Explorer 6" but that doesn't work.
<SCRIPT LANGUAGE="Javascript">
<!--
bName = navigator.appName;
if (bName =="Microsoft Internet Explorer") {
document.write('<link media="screen" rel="STYLESHEET" type="text/css"
href="stylesheet1.css">')
} else {
document.write('<link media="screen" rel="STYLESHEET" type="text/css"
href="stylesheet2.css">')
}
//-->
</SCRIPT>
View 8 Replies
View Related
Aug 23, 2006
I am fairly new the world of Javascript and need to write a javascript or vbscript to detect the version of realplayer site visitors have installed on their system, return the result, and if necessary redirect the user to a page were the player can be upgraded. Code:
View 1 Replies
View Related
Feb 1, 2011
How to do correct detection of browser and its version as it seems my code is not reliable:
PHP Code:
<script type="text/javascript">
document.write("<p>Browser: ");
[code]....
View 5 Replies
View Related
Jul 23, 2005
I have some html code i would like to be printed to the page only if the
browser has javascript enabled. I have tried to use document.writeln()
but the string i want to print bot contains some ' and " in it. I don't
know how to set the delimiters of the string that is passed as argument
so that i don't get an error in the page.
View 1 Replies
View Related
Jul 20, 2005
meta refresh tag is failing , it is supposed to go to the entry1.htm
site which is the flash swf file but it doesn't Code:
View 4 Replies
View Related
Nov 26, 2007
Simple JavaScript code for browser detection:
/**
* Browser detection
* @Created-On 2007-11-27 23:46:51
*/
function detectBrowser(){
if(navigator.userAgent.indexOf("Opera")!=-1){
return "Opera";
}else if(navigator.userAgent.indexOf("MSIE")!=-1){
return "MSIE";
}else if(navigator.userAgent.indexOf("Navigator")!=-1){
return "Netscape";
}else if(navigator.userAgent.indexOf("Firefox")!=-1){
return "Firefox";
}else if(navigator.userAgent.indexOf("Safari")!=-1){
return "Safari";
}
}
View 9 Replies
View Related
Jul 23, 2005
Can anyone recommend a good Javascript cross-browser string replace method? On both PC Mozilla Firefox and IE 6, I tried this
var str = requiredField.replace("_", " ");
where requiredField = "Ship_To_First_Name", but sadly the value of str
was "Ship To_First_Name". It seemed only one "_" had been replaced.
View 2 Replies
View Related
Aug 26, 2006
I noticed that some sites use <script src='fineName.js?ver=XXX'></script(even google) Someone told me that it's for script changes, means - if the file in
server has been changed than the new XXX will demand to load the new file.
I find it hard to believe that it's true.
View 8 Replies
View Related
May 29, 2007
I've uploaded a new version of the javascript::Minifier module that
was on CPAN. It was a translation of JSMin but I rewrote it so it now
handles missing semicolons, + ++ code, and leaves those freaky IE
conditional comments in the output. The goal was that if working code
is input then working code is output where working == working.
Breaking code that works is not such a good idea. Code:
View 4 Replies
View Related
Mar 19, 2005
I have a lot of JavaScript code I wrote to add special features and effects to my Web sites. The problem is, with the latest versions of Web browsers, all browser-side scripts are blocked. Most users who visits will either not know how to adjust their security features to allow scripts or will not want to change their settings. In a case where the script is vital to the functioning of the Web page, what is the alternative?
For example, one of my script is for a drop-down menu that takes the user to the selected section from the drop-down menu.
The other feature I need is roll-over that highlight parts of a map so that the user can make a selection.
Is there something I can add to my JavaScript code to prevent browsers from blocking it or is there a different way of using these features with a different script?
View 4 Replies
View Related
Oct 11, 2001
I'm looking for a JavaScript that does not only detects wheather the visitor uses Netscape or IExplorer, but also which version.
I would like to use one style.css for Netscape 6.x and IE 5 and up, and an alternative_style.css for Netscape 4.x.
View 2 Replies
View Related
May 5, 2003
I'm going to make an attempt at coding a nice tree menu that is decent with browser support.
I want the tree to be displayed on all browsers (well, within a decent range). Of course, on older browsers, the menu won't be as functional.
Now, I'm going to be combining the javascript with a server-side language (asp.NET) and I'll be able to do some basic browser detection on the server.
But, I read about javascript object detection and am wondering how well that works exactly.
Like, what if a browser that doesn't support objects period tries to run some object detection code? Also, which browsers support user defined objects?
See, I'm thinking of breaking down the script in 3 categories. Browsers that won't get any javascript... these would be the browsers that don't support object detection, browsers with basic javascript... with these I would be able to code my own object and I would test for different features. And then there would be the browsers that can run it all.
So, basically, my question is what browsers support what features and how should I break down my code between them? A long time ago (back in the Netscape 4 / IE4 days) I did some javascripting, but since then I haven't really done any. I remember that NS4 didn't support div tags but supported layers... anyway, it got really messy.
View 4 Replies
View Related
Mar 27, 2010
I have problems updating from version 1.7.2. to version 1.8. I'm using a custom theme - can anybody give me a step-by-step guide how to update without destroying the whole site ? :) I would like to have the button featueres in the new version
View 1 Replies
View Related
Dec 21, 2010
I am trying to get started using JQuery, but I find I can't even get to lesson #1. When I go to jquery.com and click to download the latest version (or any version) it doesn't "download" anything. It opens the file as a webpage in my browser and I see all the JQuery in one big string. Why won't the file just download? Is it the browser I am using? Is it my Mac?
View 2 Replies
View Related
Jul 23, 2005
I have a page with a script that works only in IE and as I heard from
feedbacks it doesn't run under IE on Mac.
I have browser type redirect script for that page that seems to be
working fine except it doesn't detect the OS ( IE on Mac just gives
blank page). Can someone add to the code that I would give me one page
for IE on Windows and another one for all others? Code:
View 1 Replies
View Related
Jul 20, 2005
I have on different form elements an onChange routine.
Now I was wondering how I can see which element fired the routine. Can I
write something like "if (self.name=='elementA')"?
View 1 Replies
View Related
Nov 21, 2009
I'm using the code below for the "launch page" to open a JS window and know when it has been closed, and than execute some other code that should be run after the pop-up closes.
javascript Code:
This works, and does exactly what I want. Do any of you JS experts see any reason for concern? Anything that makes it suboptimal?
View 3 Replies
View Related
Jan 30, 2007
So I need script, which will detect users browser, and if browser will be IE, then show some link in content, if browser is FireFox or Opera, then hide that link. Link looks like:
<tr>
<td align='center' valign='top'><a href='/' target='_blank'>link</a></td>
</tr>
View 4 Replies
View Related
Sep 28, 2005
I would like to have my page display the IP address of the user when the page loads. I have heard of the IP detection scripts when using the
"var ip = '<!--#echo var="REMOTE_ADDR"-->" attribute to make a window or alert popup and display the IP of the user, and I have also come some scripts that display the IP in the status bar. However, I want the current IP adress to be shown on the page itself, part of the <Body>.
View 2 Replies
View Related
Mar 23, 2006
function doDOMStuff() {
var el = document.getElementById('myElId');
// object detection
if(!document.getElementById) return false;
//or
if(!document.getElementById) return;
// doStuff
}
View 5 Replies
View Related
Jan 18, 2004
I currently have a site which uses cookies, the problem is that I want it to detect if the browser being used has cookies enabled. I know you can accomplish this by setting a cookie in JavaScript and testing for it (i don't know how to do it, though), *BUT* I need the script to be compliant with all (or at least most) browsers. By this I mean, Mozilla, Firebird, Opera, IE, Netscape, and anything else you can think of.
View 2 Replies
View Related
Oct 3, 2004
Is there a simple object detection to sniff for IE 6 only ( not IE 5.5 or lower ) ?
View 2 Replies
View Related
Apr 23, 2001
How do you find out if a certain Plugin has been installed in IE 5.5 using Javascript?
I know that in netscape you can use navigator.plugins so I was hoping there was something as easy as this.
View 2 Replies
View Related
Jul 23, 2005
How to detect that user started to scroll the page ? Separately vertical and
horizontal scroll. Is it possible ?
View 2 Replies
View Related
Jul 23, 2005
We have a database application that runs in a popup Internet Explorer
application window. The reason for this is to isolate the casual user
from the address bar and the typical IE navigation buttons.
The application has a browser test page that displays an error message
when a popup blocker is found and opens a popup page stating the test
was successfull if there is no popup blocker.
Is there a reliable method (preferably javascript) for detecting the
major popup blockers (SP2, AOL, Yahoo, Google, MSN, etc.)? We currently
have a temporary solution in place which works OK but we would like to
have a better solution.
We have already reasearched this on the net, as well as spent a few
hours trying different options.
The application is designed to run on MSIE only so the solution can be
Explorer specific.
View 26 Replies
View Related