RootsWeb.com Mailing Lists
Total: 1/1
    1. [FreeHelp] Serving different content for different browsers
    2. Barry Carlson
    3. Ten days ago, Ronald Mesnard wrote, " ... do not expect half the browsers to work unless your server hosts PHP and you present HTML targeted for the specific browser...", which is a point that needs clarification. PHP is not needed to target specific browsers, and in any case it is not available on the Rootsweb servers. However, Server Side Includes (SSI) is, and can be used to modify the content of a page in such a way that examination of the source code will give you no clue that the page you are viewing was modified at the server when it detected the User-Agent of the browser making the page request. It is also possible to load a page with Internet Explorer Conditional Comments when required, but they are only operated on by the particular browser parsing them and the code is viewable in the source of any other browser. With CSS it is possible to easily provide for Internet Explorer variances in IE5 through IE9 by creating an HTML class for each of the IE browsers you need to target, e.g. <!document html> <!--[if lt ie 6]><html class="ie5"><![endif]--> <!--[if ie 6]><html class="ie6"><![endif]--> <!--[if ie 7]><html class="ie7"><![endif]--> <!--[if ie 8]><html class="ie8"><![endif]--> <!--[if ie 9]><html class="ie9"><![endif]--> <!--[if !IE]><!--><html><!--<![endif]--> <head> etc... Which allows you to serve all your CSS in one file. Anything that needs targetting just has the class added to it, e.g. #content {width:800px;padding:20px;} .ie5 #content {width:840px;} Now lets go back to the SSI method, and though the code may look a little complex, there is no sign of that when your browser gets the right page to parse. An example of that is a very simple page designed to deliver a navy background and specific text for IE 5 through 9 browsers, a yellow background and specific text for IE10 and future IE browsers, and a pale green background with specific text for NON IE browsers. http://freepages.rootsweb.com/~bristowe/ssi-test.html For those that have IE10 preview and IE9, they will be able to check the outcome in each browser then do likewise in Firefox, Opera or Chrome. Make sure you check the source code each time! I'll post the page code including the SSI conditional expressions used later. Barry

    05/23/2012 07:54:05