Jump to content

Different browser behaviours


boen_robot

Recommended Posts

Because I'm getting bored theese days, I decided I try to make myself a site. I never thought I would encounter an issue when I wanted to make my candidate site flexible by using my favourite language- XSLT. I'm almost embarrased to ask my question, but I can't find a plausable answer myself, so here it goes...I used Piefecta's PageMaker to generate myself a good layout, instead of starting from scratch. I know it's not something that one should really do, but I though that scince I'll be using XSLT, there won't be any worries for what the XHTML nor the CSS is- I would still be able to redo the whole site without moving a single finger on the per-page contents.So far, so good. I put some of the contents in their own XML files, and copied the rest in an XSLT template.When ran on IE it's all fine, when ran in FF I see everything but the body's background color (WTF?) and Opera 9 gives "XSLT Processing failed" which is rather odd.The XSLT(layout.xsl):

<?xml version="1.0" encoding="windows-1251"?><!-- DWXMLSource="index.xml" --><!DOCTYPE xsl:stylesheet  [	<!ENTITY nbsp   " ">	<!ENTITY copy   "©">	<!ENTITY reg    "®">	<!ENTITY trade  "™">	<!ENTITY mdash  "—">	<!ENTITY ldquo  "“">	<!ENTITY rdquo  "”"> 	<!ENTITY pound  "£">	<!ENTITY yen    "¥">	<!ENTITY euro   "€">]><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" encoding="windows-1251"doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"/><xsl:template match="/"><html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><!-- The above DOCTYPE and html lines and the meta http-equiv line below the head are critical. DO NOT DELETE them -->	<head>		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />		<title>Your Page Title Here</title>		<style type="text/css" media="screen">		@import url("css/noodle_real.css");		@import url("css/style.css");		</style><!-- import with quotes and brackets hides css from:Netscape 4.xWin IE 3Win IE 4Mac IE 4.01Mac IE 4.5Konqueror 2.1.2Win Amaya 5.1isn't that nice to know? -->		<xsl:comment><xsl:text disable-output-escaping="yes">[if IE]></xsl:text>		<style type="text/css">		@import url("css/IEstyle.css");		</style>		<xsl:text disable-output-escaping="yes"><</xsl:text>![endif]</xsl:comment>	</head>	<body>	<div id="fullheightcontainer">		<div id="wrapper">			<div id="outer">				<div id="float-wrap">					<div id="center">						<div id="clearheadercenter"></div>						<div id="container-center">							<xsl:copy-of select="."/>						</div>						<div id="clearfootercenter"></div>					</div>					<div id="left">						<div id="clearheaderleft"></div>						<div id="container-left">							<xsl:copy-of select="document('navigation.xml',/)"/>						</div>					<div id="clearfooterleft"></div>					</div>				</div>				<div id="right">					<div id="clearheaderright"></div>					<div id="container-right">						<xsl:copy-of select="document('additional.xml',/)"/>					</div>				<div id="clearfooterright"></div>				</div>				<div class="clear"> </div>			</div>			<div id="gfx_bg_middle"> </div>		</div>		<div id="header">			<div class="outer_horiz_border"> </div>			<div id="subheader1">				<p>				This is Sub-Header #1 (with Fixed Height)				</p>			</div>			<div class="outer_horiz_border"> </div>		</div>		<div class="clear"> </div>		<div id="footer">			<div class="outer_horiz_border"> </div>			<div id="subfooter1">				<p>				This is Sub-Footer #1 (with Fixed Height)				</p>			</div>			<div class="outer_horiz_border"> </div>		</div>	</div>	</body></html></xsl:template></xsl:stylesheet>

style.css

/******************************************Copyright Notice: Parts of these notes are© Owen Briggs @ www.thenoodleincident.com(for the font css file) © Big John @www.positioniseverything.net and © PaulO'Brien @ www.pmob.co.uk, all of whomcontributed significantly to the design ofthe css and html code.All other content is © ClevaTreva Designs******************************************//***XXXXXXXXXXXXXXX Primary layout rules XXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXTo change many of the widths/heights requires that other certain values mustalso be changed at the same time. For this reason, beside these criticalattributes (or nearby if comment hacks do not allow) are comments with thecalculations as to how to adjust them.These guidance comments start with /*** and end with ***//***You can delete these if you want, but do not delete MAC Hack comments (seebelow).To change the width of the entire layout, adjust the columns that make up thetotal, remembering the borders. Remember, even one small mistake will degradeor even break the layout, so be very careful!For spacing within the cols, it's best to apply margins on content elementsinserted into the cols, because padding directly on those col elements willchange their widths, breaking the layout.Certain hiding hacks have been used extensively in this layout, so here is aquick explanation of them.The Safari escape tab hack:*************************** (used on wrapper, and the 3 backgrounds for Mozand Opera).Puts an escape in front of a valid number in the style name to replace aletter in that name, e.g. \65 is an e. A tab is then inserted (not a space).The purpose of this hack is to hide some code from Safari. Unfortunately,some other browsers (like IE) see it for what it should be (but NOT Safari),and so we must undo the code for those browsers by other hacks.The Tan hack:************** html .anyelement {rules read only by IE/Win and IE/Mac}The MAC hack:*************(first the active comment you are reading now must beclosed...) ***//* \*//* *//***...Back in comment mode now. Anything between those two comment lineswill be hidden from IE/Mac. Don't use any comments within this hack or it willclose prematurely and IE/Mac will begin reading before it should.The above two hacks are combined so as to feed rules only to IE/Win.The Holly Hack:***************Proper use of backslash escape characters inside property names used in theHolly hack can further segregate rules to be read by only IE6 from rules forIE5.x/Win.These hiding hacks, along with several other fixes, make possible this formerlyimpossible layout. It is highly unlikely that new browsers will have anyproblem with these valid hiding hacks, and we will have to wait for Microsoftto release IE7.If enabled in the PageMaker, the 100% height in the html and body styles makesthe design full height. It also breaks Moz because you should use min-height,but that doesn't work! Notehow these 100% heights are hidden from IE Mac withthe MAC Hack, otherwise they break it.XXXXXXXXXXXXXXX XXXXXXXXXXXXXXX XXXXXXXXXXXXXXX XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX ***/html,body{  margin:0; /*** Do NOT set anything other than a left margin for the pageas this will break the design ***/  padding:0;  border:0;/* \*/  height:100%;/* Last height declaration hidden from Mac IE 5.x */}body{  background:#33CCFF;  min-width:782px; /*** This is needed for moz. Otherwise, the header and footer willslide off the left side of the page if the screen width is narrower than the design.Not seen by IE. Left Col + Right Col + Center Col + Both Inner Borders + Both Outer Borders ***/  text-align:center; /*** IE/Win (not IE/MAC) alignment of page ***/}.clear{  clear:both;/*** these next attributes are designed to keep the divheight to 0 pixels high, critical for Safari and Netscape 7 ***/  height:1px;  overflow:hidden;  line-height:1%;  font-size:0px;  margin-bottom:-1px;}* html .clear{height:auto;margin-bottom:0} /*** stops IE browsers from displayingthe clear div/br in the page, as these are for Moz/Opera andSafari only. If IE 5.x Win DID display these, the page is too high ***/#fullheightcontainer{  margin-left:auto; /*** Mozilla/Opera/Mac IE 5.x alignment of page ***/  margin-right:auto; /*** Mozilla/Opera/Mac IE 5.x alignment of page ***/  text-align:left; /*** IE Win re-alignment of page if page is centered ***/  position:relative; /*** Needed for IE, othewise header and footer aren't containeddirectly above and below the body ***/  width:782px; /*** Needed for Moz/Opera to keep page from sliding to left side ofpage when it calculates auto margins above. Can't use min-width. Note that puttingwidth in #fullheightcontainer shows it to IE and causes problems, so IE needs a hackto remove this width. Left Col + Right Col + Center Col + Both Inner Border + Both Outer Borders ***//* \*/  height:100%;/* Last height declaration hidden from Mac IE 5.x *//*** Needed for Moz to give full height design if page content istoo small to fill the page ***/}#wrapper{  min-height:100%; /*** moz uses this to make full height design. As this #wrapperis inside the #fullheightcontainer which is 100% height, moz will not inherit heightsfurther into the design inside this container, which you should be able to do withuse of the min-height style. Instead, Mozilla ignores the height:100% ormin-height:100% from this point inwards to the center of the design - a nasty bug.If you change this to height:100% moz won't expand the design if content grows.Aaaghhh. I pulled my hair out over this for days. ***//* \*/  height:100%;/* Last height declaration hidden from Mac IE 5.x *//*** Fixes height for non moz browsers, to full height ***/  border-right:1px solid #000000; /*** Sets the external right side border. ***/  border-left:1px solid #000000; /*** Sets the external left side border. ***/  background:#003399; /*** Set background color for side columns for Safari & IE ***/}#wrapp\65	r{ /*** for Opera and Moz (and some others will see it, but NOT Safari) ***/  height:auto; /*** For moz to stop it fixing height to 100% ***/}/* \*/* html #wrapper{  height:100%;}/* Last style with height declaration hidden from Mac IE 5.x *//*** Fixes height for IE, back to full height,from esc tab hack moz min-height solution ***/#outer{  z-index:1; /*** Critical value for Moz/Opera Background Column colors fudge to work ***/  position:relative; /*** IE needs this or the contents won't show outside the parent container. ***/  margin-left:150px; /*** Critical left col dimension value = left col width ***/  width:478px; /*** Critical left and right col/divider dimension value (moves inversly) = center col width ***/  border-right:1px solid #000000; /*** Sets the internal right side border. ***/  border-left:1px solid #000000; /*** Sets the internal left side border. ***/  background:#00CC66; /*** Sets background of center col***//* \*/  height:100%;/* Last height declaration hidden from Mac IE 5.x *//*** Needed for full height inner borders in Win IE ***/}/*** The next style hack for widths are NOT needed if no internal side borders are needed ***/* html #outer{ /*** IE5.x/win box model fix ***/  width:480px; /*** Critical left and right col/divider dimension value(moves inversly) = Center Col Width + Both Inner Borders ***/  w\idth:478px; /*** Critical left and right col/divider dimension value (moves inversly) = Center Col Width ***/}#float-wrap{  width:478px; /*** Critical left and right col/divider dimension value (moves inversly) = Center Col Width ***/  margin-right:-1px; /*** Static fix, doesn't change ***/  float:left;  display:inline;}#left{  width:152px; /*** Critical left col/divider dimension value = Left Col Width + 1px + One Internal Border Width ***/  float:left;  display:inline;  position:relative; /*** IE needs this or the contents won't showoutside the parent container. ***/  margin-left:-151px; /*** Critical left col/divider dimension value = left col width + one internal border width ***/}*>html #left{width:151px;} /*** Fix only for IE/Mac = left col width + one internal border width ***/#container-left{  width:150px; /*** Critical left col dimension value = left col width - 1px ***/}#right{  float:left;  display:inline;  width:152px; /*** Critical right col/divider dimension value = right col width + 2px ***/  margin-right:-150px; /*** Critical right col/divider dimension value = negative right col width ***/  margin-left:-1px; /*** Static fix ***/  position:relative; /*** IE needs this or the contents won't showoutside the parent container. ****/}/* \*/* html #right{  width:152px;  margin-left:0px;  margin-right:-500px;  mar\gin-right:-152px;}/* Above style hidden from Mac IE *//*** These commented-out rules below are there to explain the "Critical" info     for the rules above, because comments must not appear within the Mac-hack.     The "rules" below are not active, they are just for teaching purposes.* html #right{  width:152px; Critical right col/divider dimension value = right col width + one internal border width + 1px ***  margin-left:0px; *** Critical right divider dimension value = a static 0px ***  margin-right:-500px; *** IE5.x/win fix, must be above a critical number, but very high values appear okay ***  mar\gin-right:-152px;*** Critical right col/divider dimension value  = negative (right col width + one internal border width + 1px) ***}***/#container-right{/* \*/  width:150px;/* Above hidden from IE-Mac *//*** Critical right col dimension value = right col width ***/  margin-left:3px; /*** Critical right divider dimension value = one internal border width + 2px ***/}/* \*/* html #container-right{  fl\oat:right;  di\splay:inline;  margin-left:2px;  mar\gin-left:0px;}/* Above style hidden from Mac IE *//*** Above margin left set to = one internal border width + 1px ***//*** Static fixes ***//*** a Note on the Holly hack: if IE/Win shows bugs it's a good idea to apply the height:1%     hack to different elements and see if that fixes the problem. Sometimes it may be     necessary to use "position: relative;" on certain elements, but it's hard to tell in     advance which elements will need such fixes. ***//*** This is a STATIC fix for IE5/Win at the largest text size setting. ***//* \*/* html #left{margin-right:-3px;}/* Above style hidden from Mac IE *//*** All the IE fixes that are inside seperate "Mac-hacks" may be grouped within     just one Mac-hack for convenience if desired. However, each fix must come     later than the rule it is fixing or the fix itself will be overridden. ***/#center{  width:478px; /*** Set to = center col width ***/  float:right;  display:inline;/* \*/  margin-left:-1px;/* Hidden from IE-mac */}/*** clearheader heights are made from header height + borders +any sidebar box height, less any sidebar intrusion.Similar calcs for footers. ***/#clearheadercenter{  height:72px; /*** needed to make room for header in center column ***/  overflow:hidden;}#clearheaderleft{  height:72px; /*** needed to make room for header in left column ***/  overflow:hidden;}#clearheaderright{  height:72px; /*** needed to make room for header in right column ***/  overflow:hidden;}#clearfootercenter{  height:52px; /*** needed to make room for footer in center column ***/  overflow:hidden;}#clearfooterleft{  height:52px; /*** needed to make room for footer in left column ***/  overflow:hidden;}#clearfooterright{  height:52px; /*** needed to make room for footer in right column ***/  overflow:hidden;}#footer{  z-index:1; /*** Critical value for Moz/Opera Background Column colors fudge to work ***/  position:absolute;  clear: both;  width:782px; /*** Set to Left Col + Right Col + Center Col + Both Inner Borders +Both External Borders ***/  height:52px; /*** = Bottom Margin + One Outer Border + body to footer divider depth +subfooter1 height + any other subfooter heights ***/  overflow:hidden;  margin-top:-52px; /*** negative height ***/}#subfooter1{  color: #FFFFFF;  background:#000000; /*** Background Color of Sub-footer #1 ***/  text-align:center;  margin:0 1px; /*** Margin to show left and right External Borders - all sub-headers and sub-footers ***/  height:50px; /*** sub-footer row height ***/}#header{  z-index:1; /*** Critical value for Moz/Opera Background Column colors fudge to work ***/  position:absolute;  top:0px;  width:782px; /*** Set to Left Col (not if left sidebar fully intrudes into header or left sidebar is off)+ Right Col (not if right sidebar fully intrudes into header or right sidebar is off) + Center Col + Both InnerBorders (not if any sidebar intrudes into header or footer, or Inner Borders are off) + Both External Borders(not if external borders are off) ***/  height:72px; /*** = Top Margin + One Outer Border + header to body divider depth +subheader1 height + any other subheader heights ***/  overflow:hidden;}.outer_horiz_border, .sb_outer_horiz_border{  background:#000000;  height:1px;  overflow:hidden;  font-size:0px}#subheader1{  background: #990000; /*** Background Color of Sub-header #1 ***/  text-align:center;  margin:0 1px; /*** Margin to show left and right External Borders - all sub-headers and sub-footers ***/  height:70px; /*** sub-header row height ***/}#gfx_bg_middle{  top:0px;  position:absolute;  height:100%;  overflow:hidden;  width:478px; /*** = Center Col Width ***/  margin-left:150px; /*** = Left Col Width ***/  background:#00CC66; /*** Set background color for center column for Mozilla & Opera ***/  border-right:1px solid #000000; /*** Sets the internal left side border.Remove border styles if no Internal Borders. ***/  border-left:1px solid #000000;  border-left:1px solid #000000;}* html #gfx_bg_middle{  display:none; /*** Hides the moz fix from IE ***/}

noodle_real.css

/*** The contents of this file were (ostensibly) written by Owen Briggs@ www.thenoodleincident.com, and any Copyright rests with him. Nocredit for the work that has gone into researching the use of fontsizes and styles rests with ClevaTreva Designs. 100% Kudos to Owen.This is an EDITED version of the original! You will want to play withthese settings to make your own style for fonts and color otherbits. ***/body {	font-family: verdana, arial, helvetica, sans-serif;	font-size:100.1%; /*** Don't change this setting. Make all otherfont-sizes in % (preferred) or ems ***/	color:#000000;	}a {	text-decoration: none;	font-weight: bold;	outline: none;	}a:visited {	}a:active {	}a:hover {	text-decoration: underline;	}strong, b {	font-weight: bold;	}hr {	margin: 0px; /* fixes xhtml N6 bug where the hr sits to the left*/	color: #ccc; /* for ie */	background-color: #ccc; /* for everyone else */	height: 1px;	}p {	font-size: 90%;	line-height: 1.1em;	margin-top: 1.5em;	margin-bottom: 1.5em; 	}li {	font-size: 90%;	line-height: 1.1em;	margin-top: 0.3em;	margin-bottom: 0.2em; 	}ul {	margin-top: 1.0em;	margin-bottom: 1.0em; 	}td {	font-size: 90%;	}hr {	margin-top: 2.0em;	margin-bottom: 2.0em;	}img {	border: 0;	}/*** the following styles and notes are © CopyrightBig John @ www.positioniseverything.net ***/div,p{margin:0}.italics-test, .italics-test-side {font-style: italic; text-align: justify; }/***The following fixes prevent justified italic textfrom destroying the layout in IE/win. The problemis that those properties together make IE force thecontainer wider, which in this type of floated layoutcauses a float drop.Pre-IE6 gets "width: 100%" and "overflow: hidden",while IE6 gets "width: auto" and "overflow: visible,which is the default, but explicitly stating it seemsto keep IE6 happy. IE6 also needs to see the"height: 1%" to give it some kind of box dimension.Browser coddling we call it. Finally, Bruno Fassinofound that "word-wrap: break-word;" disarranged thejustified text in IE5.5 and 6, so it is defaulted to"normal" for this text.If you don't need justified and italicized text thenforget all these fixes.Although, ClevaTreva adds, I have seen some oddbehavior with normal justified text in IE, sothis may be worth remembering.***//* \*/* html .italics-test, * html .italics-test-side {overflow: hidden;width: 100%;o\verflow: visible;w\idth: auto;he\ight: 1px;word-wrap: normal;}/* */

Not that it matters, but just to avoid the question of it, here's the IEstyle.css

/*** The rule below prevents long urls from widening floated cols and breaking the layout     in IE. It is not W3C valid, but if placed within a "Conditional comment" it will be hidden     from all user agents other than IE/Win, and thus validate. This fix fails in IE5/Win.     http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp ***/#outer{word-wrap:break-word;}

The XML files all contain only a single paragraph and some content in it simply because I'm still outlining the stuff. Something like:

<?xml version="1.0" encoding="windows-1251"?><?xml-stylesheet type="text/xsl" href="layout.xsl"?>	<p>	This is the<br />	Main Content<br />	</p>

Any idea on what might treat theese odd behaviours from FF and Opera? Could they be some sort of browser bugs or there's something wrong with my approach?[edit] On parsing on the server side, it seems the parser doesn't like my style element in the conditional IE comment. Removing it however doesn't make any difference in how browsers behave on the client side (but it does display the server side generated page fine everywhere).[/edit]

Edited by boen_robot
Link to comment
Share on other sites

OK, let's say it's a bug. If so, what might trigger it? What should I report to Mozilla and Opera?P.S. I almost can't believe IE is better then FF and Opera with this.

Link to comment
Share on other sites

I seem to be unable to get any background-color to the body with XSLT and FireFox. It must be a browser bug. I reported it already. Just instead someone is interested in a workaround: apply the background properties to the html element instead.But the minimal testcase for the background worked with Opera, so the problem with it is more complicated. Any ideas on what might be the problem with Opera? I mean, there isn't even a message to show what might be wrong.

Link to comment
Share on other sites

Thanks for all the help. Much appreciated :) .Anyway, I also solved Opera's problem now. It seems that up to the current build, Opera doesn't support the document() function and because of that returns errors.As far as I'm concerned, this topic could be closed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...