close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Browser version check (like yours)

Thread began 3/23/2009 4:15 pm by Carl | Last modified 3/25/2009 4:55 pm by Carl | 6661 views | 3 replies

Carl

Thanks all for your help.

However, I have found a way to do this that will be more precise as to which browser is using and display to them what browser they are using.

Just incase anyone fancies using this script here is the code.

<!----------------------------------------------------------------------------------->
In a file called browsercheck.php in the folder script put this code

<?php
//--------------------------------------------------------
//
// This script checks to see if the user's browser is either IE5.5 or 6.0, Safari 2 or 1, Firefox 1.
// This will then put a yellow bar at the top of the users page to notify them that the website may not function correctly
// Use this code right after the body of the site
//
// if ($oldbrowser == 'yes') {
// (((div tags go here)))
// }
//
//--------------------------------------------------------

// This code finds the root of the server
$ServerRoot = $_SERVER["DOCUMENT_ROOT"];

// This code finds the user agent the user is uing
$browser = $_SERVER['HTTP_USER_AGENT'];

//Trying to find word IE5.5 if exists, then it is IE
if (preg_match("/MSIE 5.5/", $browser)) {
$browser = "Internet Explorer";
$version = "5.5";
$oldbrowser = "yes";
$browserversion = "Internet Explorer 5.5";
}
//Trying to find word IE6.0 if exists, then it is IE
if (preg_match("/MSIE 6.0/", $browser)) {
$browser = "Internet Explorer";
$version = "6.0";
$oldbrowser = "yes";
$browserversion = "Internet Explorer 6.0";
}
//Trying to find word 1.0 Safari if exists, then it is IE
if (preg_match("/Safari\/3/", $browser)) {
$browser = "Safari";
$version = "2";
$oldbrowser = "yes";
$browserversion = "Safari 2";
}
//Trying to find word Safari/419 if exists, then it is IE
if (preg_match("/Safari\/1/", $browser)) {
$browser = "Safari";
$version = "1";
$oldbrowser = "yes";
$browserversion = "Safari 1";
}
//Trying to find word Safari/419 if exists, then it is IE
if (preg_match("/Firefox\/1/", $browser)) {
$browser = "Firefox";
$version = "1";
$oldbrowser = "yes";
$browserversion = "Firefox 1";
}
?>


<?php
if ($oldbrowser == 'yes') {
include($ServerRoot."/script/browsercheck_text.php");
}
?>
<------------------------------------------------------------------------------------>


<!----------------------------------------------------------------------------------->
In a file called browsercheck_text.php in the folder script put this code (or any other text you want to use (the image file does not work, but it is just a warning symbol))

<style type="text/css">
#OldBrowser {
background-color: #FFFF66;
padding: 10px;
width: 90%;
border: 1px solid #CCCCCC;
color: #333333;
margin-right: auto;
margin-left: auto;
font-size: 1.3em;
}
#OldBrowser img {
float: left;
margin-right: 10px;
}
</style>
<div id="OldBrowser"><img src="<?php $ServerRoot ?>/images/symbols/warning35.jpg" width="41" height="34" />We have detected that your browser is <?php echo $browser ?> <?php echo $version ?>. This site has not been fully tested on your browser and some functions may not work correctly.<br />
To make the most of this site and benefit from the security and functionality of the new browsers, we recommend upgrading to the new <?php echo $browser ?> browser.</div>
<------------------------------------------------------------------------------------>


<!----------------------------------------------------------------------------------->
Then in the main file e.g. a template put this code
<?php
$ServerRoot = $_SERVER["DOCUMENT_ROOT"];
include($ServerRoot."/script/browsercheck.php");
?>
<------------------------------------------------------------------------------------>
Hope this script helps anyone

Carl

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...