473,320 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Browser detection sends IE7 into infinite loop

37
Hi
I am trying to use browser detection to load browser specific
web pages.
The first part always seems to work ok, the Firefox page loads correctly.
Everytime I try to load the page in IE7 rather than loading the page the
browser goes into some kind of infinit loop

Expand|Select|Wrap|Line Numbers
  1. if(navigator.userAgent.indexOf("Firefox") != -1)
  2. {
  3.    window.location = "ff_enquiries.html";
  4. }
  5. else if(navigator.userAgent.indexOf("MSIE") != -1)
  6. {
  7.    window.location = "enquiries.html";
  8. }
  9.  
Can someone please help with this.
Jun 2 '08 #1
9 2436
acoder
16,027 Expert Mod 8TB
Instead of using browser detection and coding separate pages for each browser, how about coding for all browsers?

Your code could probably be condensed into one with a bit of feature/object detection.
Jun 2 '08 #2
mrhoo
428 256MB
window.location = "enquiries.html";
Do you run this on a page with a file named "enquiries.html"?.
Jun 2 '08 #3
Max58kl
37
Hi

acoder - Thanks for the advice!

mrhoo -

I have a page called Contact that has a link to the enquiries page.
I have created three enquires pages, one for IE one for Firefox and one for others.
The plan is to link the Contact page to enquiries.html which contains the following code -

Expand|Select|Wrap|Line Numbers
  1. if(navigator.userAgent.indexOf("Internet Explorer") != -1)
  2. {
  3.    window.location = "enquiries.html";
  4. }
  5. else if(navigator.userAgent.indexOf("Firefox") != -1)
  6. {
  7.    window.location = "ff_enquiries.html";
  8. }
  9. else
  10. {
  11.    window.location = "other_enquiries.html";
  12. }
  13.  
which will hopefully either load the page if IE or redirect to Firefox or Other

Regards Max
Jun 3 '08 #4
acoder
16,027 Expert Mod 8TB
Max58kl, what code do you have that doesn't work across all browsers? If you post it, we can look at changing it so that you can avoid this problem altogether. The userAgent is not reliable anyway and can be spoofed.

PS. please post code using code tags. Thanks!
Jun 3 '08 #5
Max58kl
37
Hi

Sorry about the code tags!

The enquiries page is a form with -

13 text input fields
1 text area
2 radio buttons
4 buttons
1 check box
1 submit button
1 reset button,

each field is enclosed in div tags and each field has label text enclosed in span tags,
which is all probably too much to post on the forum, especially as I have created ids
and classes for nearly every div and span tag (I don't have a great deal of experience with CSS).

I think possibly the best way to go is for you to point me to some cross browser code for laying out forms.
The current enquires.html page I made testing in IE7 which I eventually managed to get looking good,
but when I looked at it in Firefox everything was distorted.
I then duplicated the page and tweaked everything to get it to look good in Firefox.
I then looked at both the IE7 and Firefox pages in IE6 and once again both pages were very distorted.
So I duplicated the Firefox page because it was the best of the two and tweaked it to get it looking good in IE6.

Your help is appreciated!

Regads Max
Jun 3 '08 #6
acoder
16,027 Expert Mod 8TB
Since this is about laying out forms, I would suggest you start a new thread in the HTML/CSS forum. You can get it to work cross-browser using standard CSS code with possibly a few hacks to support IE. Make sure that IE is not in quirks mode by using a valid doctype. For more help, ask in the HTML forum.
Jun 3 '08 #7
drhowarddrfine
7,435 Expert 4TB
The current enquires.html page I made testing in IE7
This is why your page looked wrong in other browsers. IE7 is 10 years behind web standards and wrong in its implementation. Never use IE7 as your test browser. Always use a modern browser like Firefox/Opera/Safari for your initial test. The bugs in IE are known, as are the hacks to fix it.
Jun 3 '08 #8
Max58kl
37
Hi

Once again thanks for the advice!
Hopefully HTML/ CSS can offer suggestions.

I will now do all initial testing in Firefox.

Thanks Max
Jun 3 '08 #9
acoder
16,027 Expert Mod 8TB
The current enquires.html page I made testing in IE7 which I eventually managed to get looking good,
but when I looked at it in Firefox everything was distorted.
I then duplicated the page and tweaked everything to get it to look good in Firefox.
I then looked at both the IE7 and Firefox pages in IE6 and once again both pages were very distorted.
So I duplicated the Firefox page because it was the best of the two and tweaked it to get it looking good in IE6.
One other point to note is that there are not only three browsers (IE7, Firefox and IE6). Try to test on as many browsers and platforms as possible. You will find that if it works in, say Firefox or Opera, it will usually work in the rest more often than not (with the possible exception of IE, though that depends on how advanced the CSS used is).
Jun 4 '08 #10

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

Similar topics

7
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...
43
by: Gremlin | last post by:
If you are not familiar with the halting problem, I will not go into it in detail but it states that it is impossible to write a program that can tell if a loop is infinite or not. This is a...
17
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...
8
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...
7
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...
10
by: Steven Woody | last post by:
i have a program which always run dead after one or two days, i think somewhere a piece of the code is suspicious of involving into a infinite loop. but for some reason, it is very hard to debug....
16
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...
103
by: Tom | last post by:
How do we get out of the browser infinite loop quicksand when we navigate to web pages designed to lock us in and force us to hit the "pay me" button (whatever they want to force you to do)? ...
10
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.