FRIHOST • FORUMS • SEARCH • FAQ • TOS • BLOGS • COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Browser Validator





gidevelop
If you build a website based on firefox and on IE the display is degraded here wath you can do :

MAKE THIS STRUCTURE ON YOU FTP

www
- [site_files]
- index.phpl

IN - index.php paste the following code

Code:
<html>
<head><title>Calatorul</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>

<?php
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') )
{
   if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape') )
   {
     $browser = 'Netscape (Gecko/Netscape)';
   }
   else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') )
   {
     $browser = 'Mozilla Firefox';
?>
     <META HTTP-EQUIV='Refresh'CONTENT='5; URL="http://localhost/site_files/index.php"'>
<?php
   }
   else
   {
     $browser = 'Mozilla (Gecko/Mozilla)';
   }
}
else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') )
{
   if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') )
   {
     $browser = 'Opera (MSIE/Opera/Compatible)';
   }
   else
   {
     $browser = 'Internet Explorer (MSIE/Compatible)';
?>
     <META HTTP-EQUIV='Refresh'CONTENT='5; URL="noexp.php"'>
<?php
   }
}
else
{
   $browser = 'Others browsers';
}

echo $browser;
?>
</body>
</html>



USAGE: you will find $browser = 'Netscape (Gecko/Netscape)'; for example. That will display wath kind of browser you are running. Now you can remove it or add the command you like. Put your codes between the IF command bracket {}

EXAMPLE


...
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') )
{
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape') )
{
$browser = 'Netscape (Gecko/Netscape)';
}
else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') )
{
$browser = 'Mozilla Firefox';
?>
<META HTTP-EQUIV='Refresh'CONTENT='5; URL="http://localhost/site_files/index.php"'>
<?php

}
else {...}

EXPLANATION
:

As you can see you can also break the php command and insert some html code (see red lines)
In the read lines above i've inserted a META that refresh after checking wait 5 sec and redirect to my desired URL

COMMANDS:

HTTP-EQUIV='Refresh' - do refresh
CONTENT='5 - do wait 5 sec
URL="http://localhost/site_files/index.php" - do redirect

ANOTHER FINE ONE FROM GIDevelop !!!

If you get into trouble post your questions here !!!
alalex
neat way of improving the display!
i will most probably give it a try in a few days, i will post here how did it go!
well, keep up this good tuts Wink
gidevelop
I'am really glad that just some of us appreciate a good work when they see it!


SORRY. This is burs of fury Very Happy Very Happy Very Happy
qscomputing
Well it works but you must NEVER use a technique like this. The web is supposed to work equally well in any browser, and trying to restrict your users to one (or a limited selection of) browsers is wrong.

It's a much better idea to follow the standards (they exist for a reason) and code so that your page degrades gracefully in less-capable browsers. Include any quirks for IE but stay with the standards.

And never try to give someone a different page or lock them out based on their browser.
ThomasDesigns
qscomputing wrote:
Well it works but you must NEVER use a technique like this. The web is supposed to work equally well in any browser, and trying to restrict your users to one (or a limited selection of) browsers is wrong.

It's a much better idea to follow the standards (they exist for a reason) and code so that your page degrades gracefully in less-capable browsers. Include any quirks for IE but stay with the standards.

And never try to give someone a different page or lock them out based on their browser.

good advice.

What if a future client of yours uses a non-mainstream browser? Long story short, they won't be your client anymore.

@ gscomputing:
'graceful degrading' is a nice term. I like it.
qscomputing
ThomasDesigns wrote:
'graceful degrading' is a nice term. I like it.

I forget where I got it from - I think it's a term used by the W3C but I'm not entirely sure.
gidevelop
Is not necessarily to ban IE users or force him to download Gecko Engine Browser it can be used for eq to redirect him to another index build for IE display. I have build-up this because many times happens to me to get a missed display on IE because i build my sites over firefox.

HOPE I'VE MADE MY SELF CLEAR !!!
ThomasDesigns
gidevelop wrote:
many times happens to me to get a missed display on IE because i build my sites over firefox.


Yeah, thats all he was saying is that you should design your code to, ah hem, Degrade Gracefully. Your script is nice and everything, I'm sure you are proud of it. However if you code adhering to the WC3 standards, it is far less work because if your site looks alittle different, yet still nice, in all browsers, and you only had to write the page one, thats nice. Honestly it takes less time and effort to tweak your code to degrade rather than code a different layout for each browser, and time is money.
manav
r u a firefox fan or somethin???

ur work is good but...why do u need to ban some browser users???

i ahve seen some firefox ppl doin it...

and they act a real spoilt sport when they do it....
gidevelop
You get me wrong!! I don't want to ban other browser user. This is a piece of code for temporary usage witch means that you can redirect the different browser users to a version of your site witch is compatible with their browser until your site meets all browsers competence w3c xml css validations . Or... yeah you can ban certain browsers if you are an exclusive of certain browser/browsers. This script has a lot of potential. I mean if you are an affiliate of a browser brand you can sneak a link to send your referal to that site that supports that browser so that is way sometimes is better to ban other browsers users.. to force them to download the browser you want to. I do not do that tough, is not nice !!! Wink
Arnie
Oh really? So why does the code say...
gidevelop wrote:
else
{
$browser = 'Internet Explorer (MSIE/Compatible)';
?>
<META HTTP-EQUIV='Refresh'CONTENT='5; URL="noexp.php"'>


So when you're using IE, you get redirected to "noexp.php".
"No Explorer" ? Hmm...
Fire Boar
gidevelop wrote:
Code:
   else
   {
     $browser = 'Internet Explorer (MSIE/Compatible)';
?>
     <META HTTP-EQUIV='Refresh'CONTENT='5; URL="noexp.php"'>
<?php
   }


No no no no no no NO!

Sheesh, don't ever use this! Use the following instead:

Code:
   else
   {
     $browser = 'Internet Explorer (MSIE/Compatible)';
     header('Location: noexp.php');
   }


Much better. Much nicer. Much more good. Or even...

Code:
   else
   {
     $browser = 'Internet Explorer (MSIE/Compatible)';
     require('noexp.php');
     die();
   }
gidevelop
@ Arnie .... dude.. this is an example script witch can have a lot of purposes. If not like it not use it okay. Second... i am a good programmer not a BEST one i've copy it it from my pc the way it was in that time and in that time a was testing the ban thing. C'mon people what is wrong with you !!! All this talking because a stupid script... Geeez!!! And for the last time: IT'S A TESTING SCRIPT !!!
Arnie
Sure it can be used for other purposes, I just disapprove of the idea / sentiment that's clearly behind it as I previously showed. Discussion closed as far as I'm concerned...
Related topics
GIF and JPEG.
which kind of browser do u use
*OFFICIAL* Which Browser do you use?
Netscape patches 1-day-old browser
Spoofing in Mozilla ( FireFox) browser flaw
Okay, I'm done trying to use CSS for layout.
... And the browser trophy goes to ...
Site Nav Suggestions...
Sόper firefox eklentileri
Website Icons?
Speed Up Firefox Browser Upto 10 times!!!
Firefox Problem!
Opera (the web browser) is now FREE!!!
what is the best web browser?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.