473,664 Members | 2,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

browser detection

2 New Member
sorry, I put the original text instead of my changed one in the previous mail sorry

hello,

I am new to this forum and a laymen. I have awebsite www.earlyflute.com. I make baroque flutes as you can see there. I renewed my site recently using ap div s and dreamweaver in a template and css to get away from my fifteen yr old frontpage one. However it did not work with IE6 as you probably know. So I made a second version for IE6 and tried to use the browser detection java script shown below. As long as the browser is not IE I get the right version earlyflutenew7, but for IE7 I get version earlyflutenew6 and sometimes it seems from the web statistics that users get the 7 one for IE6. I dont understand it. Please, thisi important for me could somebody solve it????

[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Browse r detection</Title>
<Script Language="JavaS cript">
// Browserdetectio nscript made by Henrik Petersen / NetKontoret
// Script explained at www.echoecho.co m/javascript.htm
// Please do not remove this and the two lines above.
// Detect the browsername
browsername=nav igator.appName;
{if (browsername.in dexOf("Microsof t")!=-1) {browsername="M SIE"}
else {browsername="N/A"}};

//detect the browserversion
browserversion= "7";
if (navigator.appV ersion.indexOf( "3.")!=-1) {browserversion ="3"};
if (navigator.appV ersion.indexOf( "4.")!=-1) {browserversion ="4"};
if (navigator.appV ersion.indexOf( "5.")!=-1) {browserversion ="5"};
if (navigator.appV ersion.indexOf( "6.")!=-1) {browserversion ="6"};


// Send visitor to relevant pages
if (browsername==" MSIE")
{
if (browserversion <7){window.loca tion="http://www.earlyflute. com/earlyflutenew6/index.html"}
else {window.locatio n="http://www.earlyflute. com/earlyflutenew7/index.html"}
}
if (browsername==" N/A") {window.locatio n="http://www.earlyflute. com/earlyflutenew7/index.html"};
</script>
</head>
</body>
</html>
[/HTML]


Regards,

Simon
Oct 19 '07 #1
4 2167
JosAH
11,448 Recognized Expert MVP
You've asked your question in the Java Articles section where it doesn't belong.
I've moved your question over to the Javascript forum. Good luck.

kind regards,

Jos
Oct 19 '07 #2
gits
5,390 Recognized Expert Moderator Expert
hi ...

you may have a look at our javascript-articles section, where you will find an answer to your questions, but i strongly recommend not to use browser-detection ... rather use object detection. what that means you can find here ... that is a much better solution and you should consider to use that for you. in case you would have particular problems with it please post back anytime ...

kind regards
Oct 19 '07 #3
sjpolak
2 New Member
Hi you are probably right that I should rather use object detection, but people visiting my website will 99% use either IE(6 or 7) or firefox or safari as I know from many yrs statistics. However, I am quite pleased with myself because I found the problem I think. The code I used from some henrik peterson etc, simply is wrong. In the string where it searches for 5. for instance the 5. may be found in another place then for the version. That makes it go wrong for version detection. I now use another small piece of code that does a parsing such that the number in the right place is used.

Sorrry, you probably will not hear from again.

Regards,

simon
Oct 19 '07 #4
gits
5,390 Recognized Expert Moderator Expert
hi ...

glad to hear you got it working ... in case you have more problems ... then post in the forum again :)

one question regarding to your current (resolved) problem ... do you really need to detect all the versions? as far as i can see you only have 3 cases ... IE 7 or < 7 and the rest of the browsers ... do you need the version-numbers for other code? in case you don't then simply try to detect version 7 and leave the rest as IE or the other browsers ...

kind regards
Oct 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
10067
by: Szar | last post by:
JS noob. I've seen plenty of browser detection scripts but they all seem to be slightly different and don't really fit my needs. I have various places where if the browser is IE I'd like to display else . For example, if a browser is IE I want to use this CSS file otherwise use a different one and if it's IE make this cell x pixels high else make it y pixels high. I'm sure this is easy, please excuse my stupidity. Steve.
17
2541
by: lawrence | last post by:
How is it possible that the question "How do I detect which browser the user has" is missing from this FAQ: http://www.faqts.com/knowledge_base/index.phtml/fid/125 and is only here on this with a link to old information that suggests use of "navigator": http://developer.irt.org/script/43.htm
8
4544
by: R. Smits | last post by:
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"
8
1675
by: Jimnbigd | last post by:
What is the recommended code to test browser type, for conditional processing in Javascript? I have seen tests for "document.all". I have seen tests for the actual browser name, or substrings in the browser name. What do you all recommend? Thanks...Jim...
7
1925
by: phal | last post by:
Hi I think there are many different browsers to browse to the Internet, how can I write the javascript to identify different browser and display according to the users. Some browser disable the javascript by default or by the user, how can i solve this problem if the javascript is disable. thank you
4
2568
by: trpost | last post by:
I am looking for a script using javascript to pull browser information including, browser type and version, OS info, plugins (flash, acrobat, media player, etc), java version, etc. that will work on IE/Firefox. I am looking for detalis similar to what is available at: http://www.webreference.com/tools/browser/_browserhawk.html Thanks!
15
2313
by: CMM | last post by:
So I'm half way through overseeing a large project in ASP.NET 2.0. My superiors have decided that it would be nice if we ensured the site worked on all the major platforms (as they see it: IE, FireFox, and Safari). We've made heavy usage of the new MENU control and other intrinsic 2.0 controls.... nothing fancy! just using ASP.NET's built-in controls and very nice, pervasive, and clean usage of CSS. Now I find after more testing that the...
16
2345
by: petermichaux | last post by:
Hi, Does anyone have a a cross-browser setOpacity function that does not use browser sniffing? I looked at the Yahoo! UI function and it detects IE by looking for window.ActiveXObject. I also looked at Scriptaculous and it uses navigator.userAgent. Thanks, Peter
7
2997
by: Nathan Sokalski | last post by:
I want to make sure I am doing a browser detection that will work once IE7 is released. My current detection statement (written using VB.NET) is: If Me.Request.Browser.Browser.ToUpper() = "IE" Then 'Code to use for Internet Explorer browsers Else 'Code to use for browsers other than Internet Explorer End If
10
3252
by: Conrad Lender | last post by:
In a recent thread in this group, I said that in some cases object detection and feature tests weren't sufficient in the development of cross-browser applications, and that there were situations where you could improve the application by detecting the browser vendor/version. Some of the posters here disagreed. Since then, I've had to deal with a few of these cases; some of them could be rewritten to use object detection, and some couldn't....
0
8437
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8861
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8778
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7375
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4185
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1759
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.