Maurice79 Posted February 26, 2009 Share Posted February 26, 2009 I use basically only firefox for all my internet browsing and edited/created a few webpages. By accident i used IE to visit the pages and couldn't believe my eyes, it are totally different pages when viewing them with IE! Everything is messed up and borders are added i never added to the script or heights i never put that high. How is this possible? Is it possible to block the pages for IE users because i don't want people see the pages in IE view. To see what i mean click here. Quote Link to comment https://forums.phpfreaks.com/topic/147073-ie/ Share on other sites More sharing options...
The Little Guy Posted February 26, 2009 Share Posted February 26, 2009 why not just code for both browsers? Quote Link to comment https://forums.phpfreaks.com/topic/147073-ie/#findComment-772113 Share on other sites More sharing options...
Maurice79 Posted February 26, 2009 Author Share Posted February 26, 2009 I can't, i rarely know what i did now to create it. How is this possible because other sites look the same in IE and FF, can't i just block IE users form the pages, sorry for IE users but if you don't use a proper browser you dont earn the pages. Ofcourse the last thing i said is a joke, im just pissed off IE fuck up the pages and it seems i did everything for nothing because IE and FF users should view both the pages. Quote Link to comment https://forums.phpfreaks.com/topic/147073-ie/#findComment-772132 Share on other sites More sharing options...
The Little Guy Posted February 26, 2009 Share Posted February 26, 2009 <?php $_AGENT = $_SERVER['HTTP_USER_AGENT']; if(preg_match("~.+?MSIE.+?~",$_AGENT)){ echo 'You have IE'; }else{ echo 'You don\'t have IE'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/147073-ie/#findComment-772168 Share on other sites More sharing options...
Daniel0 Posted February 26, 2009 Share Posted February 26, 2009 No... 1) You don't understand regular expressions properly. .+?MSIE.+? is the same as just MSIE. 2) Regex is overkill. Just use strpos. However, 3) Browser detection cannot be relied on. See: http://webaim.org/blog/user-agent-string-history/ 4) Blocking users like that is bad. The text can be read just fine even though some things may be mispositioned. Just use IE conditional comments to display a message to the user telling them to upgrade to a newer version of IE or pick a better browser. In that way they can still read the content with a broken layout. Quote Link to comment https://forums.phpfreaks.com/topic/147073-ie/#findComment-772187 Share on other sites More sharing options...
nrg_alpha Posted February 26, 2009 Share Posted February 26, 2009 Or you could do this: echo (preg_match('#MSIE#',$_SERVER['HTTP_USER_AGENT']))? 'You are using IE. I\'m so sorry :*(' : 'Wlecome to the modern world, non IE user!'; Granted, not all IE versions are equal.. perhaps checking to see which version is in use if it is used? if (preg_match('#MSIE (\d+)#', $_SERVER['HTTP_USER_AGENT'], $match)){ if ($match[1] < 7){ // send the user to hell and make'em pay!!! } else if($match[1] == 7){ // IE 7 detected.. // Ok, version 7 is better than 6 or under, proceed... } } or, if you are knowledgable enough with apache mod_rewrite, I think you can have built in redirects using an .htaccess file. EDIT - Or strpos as Dan mentioned would work too. Quote Link to comment https://forums.phpfreaks.com/topic/147073-ie/#findComment-772190 Share on other sites More sharing options...
nrg_alpha Posted February 27, 2009 Share Posted February 27, 2009 See: http://webaim.org/blog/user-agent-string-history/ Interesting synopsis of the browser emulation evolution. Certainly (in the case of 'MSIE', older browsers (such as older Opera versions) did indeed have those letters in the value of $_SERVER['HTTP_USER_AGENT'] (but not so much anymore). Searching for 'Mozilla' will still definitely cause some issues I would think. From what I read once, it is ultimately better to test for browser features instead of browser agent info and make decisions based on that. If one does check through agent info, I suppose it's best to really make some additional checks to ensure they have the correct agent to begin with. I'm not so terribly concerned with "MSIE" to be perfectly honest. I would be with "Mozilla" though. Quote Link to comment https://forums.phpfreaks.com/topic/147073-ie/#findComment-772197 Share on other sites More sharing options...
Daniel0 Posted February 27, 2009 Share Posted February 27, 2009 The point of the article is that you risk breaking future application in this way. Quote Link to comment https://forums.phpfreaks.com/topic/147073-ie/#findComment-772219 Share on other sites More sharing options...
Vermillion Posted March 1, 2009 Share Posted March 1, 2009 Code on XHTML strict. When I was working on my second website, I was able to code properly for IE, Firefox and other Mozilla based web browsers. I did that by coding on XHTML Transitional. ... But later I considered the fact that a lot of people use Safari as their browsers. Google Chrome is widely used now as well, and both have the same rendering engine. They I tried my XHTML Transitional website on those browsers. And lord should you have seen the mess I created. Later I found out that coding on XHTML Strict increases your chances of making a website that looks fine on almost every browser. Checking the user client with PHP is not always a reliable method. I heard that people can choose whether they can send the client information to the server or not. Quote Link to comment https://forums.phpfreaks.com/topic/147073-ie/#findComment-773660 Share on other sites More sharing options...
Daniel0 Posted March 1, 2009 Share Posted March 1, 2009 Code on XHTML strict. Fixed. Unless you serve it as application/xhtml+xml it'll de jure get parsed and interpreted as HTML by the browsers anyway, but if you serve it as such then you'll cut off all IE users. Quote Link to comment https://forums.phpfreaks.com/topic/147073-ie/#findComment-773681 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.