Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript - making website compatible with Firefox

Status
Not open for further replies.

scrafts

Technical User
Jan 18, 2003
37
US
The website in question currently checks, via JavaScript, to see if the browser is IE or Netscape. The commands use a test like:

if (navigator.appName == "Microsoft Internet Explorer"...)

the AppName for MSIE is as above, and the AppName for Netscape is "Netscape".

My question is where can I find out the AppNames for Firefox, Gecko, Opera, etc. Now that Firefox is becoming popular, I would like to at least get that one working.

Thank you very much.

 
I agree with Foamcow. These days, all you would possibly need to check for is whether or not the browser is IE garbage or Netscape-esque.

*cLFlaVA
----------------------------
[tt]Sigs cause cancer.[/tt]
 
Well, as much as I appreciate hearing your opinions, I am really looking for an answer.

Unfortunately, there is a graphical anomoly which does not manifest itself with MSIE but is apparent in Netscape. I therefore needed to create two (slightly) different index pages to compensate. Though this is invisible to the user, they are redirected to the version which will display properly in their browser. I noticed that Firefox also displays this anomoly so I wanted to find out the correct string returned to AppName so that the user would see the page properly displayed.
 
Testing for one string, Microsoft Internet Explorer, should be fine. If the anomaly occurs in other browsers, you can serve one page for IE users and another page for all other users.

*cLFlaVA
----------------------------
[tt]Sigs cause cancer.[/tt]
 
What is the anomoly? Maybe I(we) can help with that.
Do you have a link to the page in question?

If you need to detect user agent strings then you can get that info from weblogs.
In fact Opera and Firefox have the ability to identify themselves as another browser by means of a custom user agent string. You might get them from that.

and there is always Forum216

Foamcow Heavy Industries - Web design and ranting
Toccoa Games - Day of Defeat gaming community
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
"I'm making time
 
I followed the advice of cLFlaVA and made one test that will send the user to the MSIE index page if Explorer is the browser, and will send all others to the Netscape index page. I will have to see how this looks when I get a chance to check it with Firefox and others. Foamcow - the website is The anomoly is a one-pixel shift appearing up near the circular logo. If the shift is present, then you will see a tiny stairstep between the dark blue menu/title area and the light blue main window area. This will appear just to the right of the logo. If you don't see this when you check it using Firefox, then I guess cLFlaVA's solution worked.

The way I implemented it was as follows:

<SCRIPT LANGUAGE="JavaScript">
<!--

var browser = navigator.appName;

if (browser.search(/microsoft/i) == 0)
{
location.href = "mvi_index_Microsoft.htm"
}
else
{
location.href = "mvi_index_Netscape.htm"
}

//-->

</SCRIPT>

Thanks a lot.
scrafts
 
I can still see the stepping.

I'm not a fan of frames and consequently I'm a bit rusty with them. But a quick look at your code for the frames in question revealed this

in the logo frame you have

Code:
<BODY BACKGROUND="images/blue_bg.gif" SPACING=0 MARGINHEIGHT=0 MARGINWIDTH=0>

while in the title frame you have this
Code:
<BODY BACKGROUND="images/blue_bg.gif" TOPMARGIN=0 LEFTMARGIN=0 SPACING=0 MARGINHEIGHT=0 MARGINWIDTH=0>

Could that difference (i.e. specifying topmargin and leftmargin in one and not the other) be the source of your problem?

Looking at the site there is no reason I can see that your layout could not work with simple cross browser code with no need for JavaScript sniffers (or frames for that matter, but you must want them for a reason ;-) )

Foamcow Heavy Industries - Web design and ranting
Toccoa Games - Day of Defeat gaming community
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
"I'm making time
 
I have never seen a problem with the stairstepping effect on MSIE. I have three computers here running XP Pro, and a dozen at work running Win2K. They all use MSIE 6.

The solution to the shift problem was to make a second version of the logo with a one-pixel shift of the background to compensate for the stairstepping.

I do appreciate the suggestions, but obviously I have to find the answer to my original question in order to solve this problem.
 
There is a reason for that. I downloaded the Firefox browser and ran a little JavaScript on the page:

<SCRIPT LANGUAGE="JavaScript">
<!--

function browsername()
{
var browser = navigator.appName;
alert("Browser in use: " + browser);
}

//-->
</SCRIPT>

It came back with the string "Netscape". Since it was also displaying this anomoly, I tried sending it to the Microsoft version of the page instead. It displayed fine, so I have now removed the test and I am sending all browsers to the same version of the page.

I originally coded the test because I was encountering the problem when browsers were at version 4. I am guessing that in subsequent versions of Netscape and Mozilla browsers, the problem has been resolved, making my original solution obsolete.
 
I originally coded the test because I was encountering the problem when browsers were at version 4 [...] the problem has been resolved, making my original solution obsolete.
That's what Foamcow and cLFlaVA were trying to tell you in posts 2 & 3 of this thread.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
ChrisHunt - As much as I appreciate your extremely valuable contribution to this thread, none of the previous posts answered my original question: "My question is where can I find out the AppNames for Firefox...". However, I appreciate the contributions of Foamcow and cLFlaVA because they were trying to help!
 
Since I was able to get the value returned by Firefox via the JavaScript, I was able to determine which version of the index page worked properly. Fortunately it was the same one that I was using for MSIE, so I have been able to remove the sniffer code (but I am keeping the frames because I need to write different info to the main window frame and the page title frame).
 
IFRAMES and/or server side includes don't suffer from as many restrictions/issues as frames do.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top