a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Hosting from $3.99 per month!

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions. dd

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Display Code Based on Browser

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> General Web Development >> Display Code Based on Browser
Page: [1]
 
BobbyDouglas

 

Posts: 5479
Joined: 5/15/2003
From: Arizona
Status: offline

 
Display Code Based on Browser - 6/6/2005 17:11:27   
For those people who use certain hacks for browsers, such as the IE min/max hack, then this is something you will want to implement!

Why have a FireFox user load hacks that are only for IE? I see no reason.

The two main uses for this are for JavaScript for IE only, or the MSSmartTagsPreventParsing for IE as well.

Here is an example of code used to display these IE only attributes when the browser is IE.

Place this at the beginning of your document. If you wish to make it an include, it will be easier in the long run if you decide to add more browsers to the list:
<?php
$is_ie = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE');
?>


Example code using the MSSmartTagsPreventParsing for IE only.
<?php
if ($is_ie) echo "<meta name=\"MSSmartTagsPreventParsing\" content=\"true\" />
";
?>


Be sure to change each " to a \" when you place your code between echo "you-code-goes-here"

<meta name=\"MSSmartTagsPreventParsing\" content=\"true\" /> will only display in the source code when the browser is IE. This is a tag that only IE uses, so there is no reason for someone to display it in all of the browsers.

Note that this code only runs on PHP pages, if you are not sure if it will work on your hosting account, please ask your host.

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge
Page:   [1]
OutFront Discoveries

All Forums >> Web Development >> General Web Development >> Display Code Based on Browser
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts