Firefox not reading IE conditional statement as a comment |
Firefox not reading IE conditional statement as a comment |
Fireater989 |
Aug 8 2010, 01:25 PM
Post
#1
|
Group: Members Posts: 3 Joined: 8-August 10 Member No.: 12,456 |
I chose to redirect users using IE to another webpage asking them to upgrade to another browser. The only way to do this without using JS is through IE conditional statements. I won't use a meta refresh, for obvious reasons. I can't use .htaccess because there's no way to use conditional statements with that. I decided on a php script because my page was already php.
My website is http://spotlight.isgreat.org/ I inserted the script via php include so it shows up as regular html. Here's the script that I put in the head tag: <!--[if IE]> <? header( "Location: http://www.spotlight.isgreat.org/ie.html" ); exit(0); ?> <![endif]--> These particular statements trigger on all versions of IE and all other browsers should treat it as a comment, however, Firefox redirects, every time. So, it triggers in IE, as it should, and FF, as it shouldn't, and doesn't trigger in Chrome, as it should, and Safari, as it should. Sooooooo, Why is this happening in Firefox? I feel like there is a simple answer staring me in the face... This post has been edited by Fireater989: Aug 8 2010, 01:33 PM |
Christian J |
Aug 8 2010, 02:47 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
I chose to redirect users using IE to another webpage asking them to upgrade to another browser. Why not make your site work in all browsers instead? QUOTE Here's the script that I put in the head tag: <!--[if IE]> <? header( "Location: http://www.spotlight.isgreat.org/ie.html" ); exit(0); ?> <![endif]--> That can't work since PHP is run by the server, not the browser, and the server doesn't care about conditional comments. I'm actually surprised it can redirect at all, since the PHP manual says that header() must be called before any actual output is sent. BTW I get redirected in all my browsers, including Safari/Chrome. Edit: removed whiny comment. This post has been edited by Christian J: Aug 8 2010, 03:16 PM |
pandy |
Aug 8 2010, 02:51 PM
Post
#3
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
FYI I got redirected with every browser I tried, that includes Opera, Iron and Safari Windows.
[ADDED] Oops! Christian was quicker. |
Fireater989 |
Aug 8 2010, 03:31 PM
Post
#4
|
Group: Members Posts: 3 Joined: 8-August 10 Member No.: 12,456 |
Hmmmm.
Well, I knew at least one person was going to tell me to make my website cross browser compatible. The reason why not is because I am using some new HTML5 elements and CSS3 properties that are not supported with any version of IE and I choose not to apply countless CSS and JS hacks to get the effect I want. Besides, you can get more functionality out of any other browser than IE and it's a small drop in the bucket towards making it die. Thanks a ton for your feedback about php, I guess I will have to stick with a meta refresh, I don't want much traffic from search engines anyway due to the nature of the service I'll be doing |
pandy |
Aug 8 2010, 03:58 PM
Post
#5
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
Your site must be truly amazing if you think people will install another browser to use it. Me, I have a lot of browsers, but mostly I wouldn't even bother to start another one.
|
Darin McGrew |
Aug 8 2010, 06:43 PM
Post
#6
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
The more things change, the more things stay the same:
http://htmlhelp.com/feature/art2.htm |
Christian J |
Aug 8 2010, 06:49 PM
Post
#7
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
Hmmmm. Well, I knew at least one person was going to tell me to make my website cross browser compatible. Of course: "The Web Design Group was founded to promote the creation of non-browser specific, non-resolution specific, creative and informative sites that are accessible to all users worldwide." QUOTE The reason why not is because I am using some new HTML5 elements and CSS3 properties that are not supported with any version of IE and I choose not to apply countless CSS and JS hacks to get the effect I want. Besides, you can get more functionality out of any other browser than IE and it's a small drop in the bucket towards making it die. Isn't it possible to use these new functions as progressive enhancements, while still showing non-supporting browsers the actual content? |
Fireater989 |
Aug 8 2010, 07:59 PM
Post
#8
|
Group: Members Posts: 3 Joined: 8-August 10 Member No.: 12,456 |
I haven't designed it to be browser specific, IE just happens to be the only browser not supporting standards. I don't cater to blind or disabled customers, just some Facebook friends as a side hobby. And sure, maybe it won't look so bad when IE9 comes out, I'll change my conditional to [if lt IE 9]. I understand that many developers feel strongly about cross-browser support, I see your side and agree with you, but it just doesn't suit my purposes. Thanks Christian for your help with the redirect. I'm done with the discussion -_-
|
pandy |
Aug 8 2010, 09:17 PM
Post
#9
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
Neither HTML5 nor CSS is a standard.
|
Brian Chandler |
Aug 8 2010, 10:39 PM
Post
#10
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
QUOTE I inserted the script via php include so it shows up as regular html. Here's the script that I put in the head tag: CODE <!--[if IE]> <? header( "Location: http://www.spotlight.isgreat.org/ie.html" ); exit(0); ?> <![endif]--> These particular statements trigger on all versions of IE and all other browsers should treat it as a comment, however, Firefox redirects, every time. So, it triggers in IE, as it should, and FF, as it shouldn't, and doesn't trigger in Chrome, as it should, and Safari, as it should.Sooooooo, Why is this happening in Firefox? Nobody has actually answered your question, so I will try. The reason is that the PHP header() function does not output text into the html file (where it would indeed be ignored by everything except IE). header() sends an http header, which is part of the information sent before the <html> document even starts. In fact, you should generally get the php error message objecting to calling the header() function once the text output has started; but you may have the option switched on to delay sending the html until the end of php program execution. So if you use wget or similar to view the actualy document being sent, you will see that the conditional comment is empty. If you are using php anyway, you could simply check the user agent string, and determine the content to send accordingly. HTH |
Christian J |
Aug 9 2010, 06:54 AM
Post
#11
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
you may have the option switched on to delay sending the html until the end of php program execution. What's that option called? QUOTE If you are using php anyway, you could simply check the user agent string, and determine the content to send accordingly. Note that UA sniffing is not very reliable. I'd use a META or JS redirect inside a CC. |
Brian Chandler |
Aug 9 2010, 07:41 AM
Post
#12
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
you may have the option switched on to delay sending the html until the end of php program execution. What's that option called? Hmm, hoped you wouldn't ask... looks like: output_buffering There's also a couple of functions to buffer output and flush buffer. See in the php manual for header(). QUOTE QUOTE If you are using php anyway, you could simply check the user agent string, and determine the content to send accordingly. Note that UA sniffing is not very reliable. I'd use a META or JS redirect inside a CC. What is the most reliable way of detecting a pukkah MSIE? I would hope that fewer and fewer people are going around pretending to be MSIE with other browsers... Can we assume that no other browser will interpret inside CC? |
Christian J |
Aug 9 2010, 10:36 AM
Post
#13
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
Hmm, hoped you wouldn't ask... looks like: output_buffering There's also a couple of functions to buffer output and flush buffer. See in the php manual for header(). http://php.net/manual/en/outcontrol.configuration.php says output_buffering is off by default, but in my php.ini it was on. Can't believe I've enabled it myself. Once again I'm reminded to keep copies of default settings. QUOTE What is the most reliable way of detecting a pukkah MSIE? I would hope that fewer and fewer people are going around pretending to be MSIE with other browsers... I think CCs is totally reliable so far (but who knows about the future?). It can't easily be spoofed (like a UA), deals with the browser version itself (as opposed to JS object detection or CSS hacks, that rely on indirect evidence) and doesn't require that the user has JS enabled. QUOTE Can we assume that no other browser will interpret inside CC? I don't know of any other browser supporting them. But you can get the content of a CC with non-IE browsers with JS, so I guess it's theoretically possible that someone ran such a user script in his non-IE browser. |
Lo-Fi Version | Time is now: 19th April 2024 - 07:53 AM |