Browsing Posts in HTML4/CSS2

Just a few notes here for personal reference. For people un-familiar with PHP, get_browser(); is a nifty little function that allows server-side scripting to detect browser capabilities. However it does rely on the browscap.ini directive in PHP.INI being enabled and using a valid path to a browscap.ini file somewhere.

Trouble is browsers seem to be changing every five minutes, and new ones added, so keeping an up-to-date list is somewhat of a nightmare.

One Gary Keith whose made it his life's mission to keep an up-to-date browscap.ini file for the developers of the world. As an addendum. Thank You ! : )

http://browsers.garykeith.com/downloads.asp

Some other info. for personal reference, as this is what started this whole tangent in the first place, is IE7 Compatibility View. A feature that Microsoft have enabled in IE8 to force IE7 standards mode to provide some backwards-compatibility in their new browser.

There is a nifty little tag you can include in your HTML to force this, and by default it also disables the IE7 Compatilbilty View button in IE8. Nice !

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

Here's the official Microsoft splurge about it : http://msdn.microsoft.com/en-us/library/cc817574.aspx

Something worthy of note :

"The X-UA-compatible header is not case sensitive; however, it must appear in the Web page's header (the HEAD section) before all other elements, except for the TITLE element and other META elements."

Some quick PHP IE detection script. Returns major version. i.e. 6,7,8 etc...

<?php
$sUA = $_SERVER['HTTP_USER_AGENT'];
function getInternetExplorerVersion($sUA){
	// RegEX courtesty of Microsoft MSDN : http://msdn.microsoft.com/en-us/library/ms537509(VS.85).aspx.
	preg_match('/MSIE ([0-9]{1,}[\.0-9]{0,})/',trim($sUA), $arrMatches);
	if(ini_get('browscap')){
		if(function_exists('get_browser')){
			$arrBrowserComponents = get_browser(null, true);
			if(!empty($arrBrowserComponents['version'])){
				return floor($arrBrowserComponents['version']);
			}else{
				// Use fall back method
				if(isset($arrMatches[1]) && !empty($arrMatches[1])){
					return floor ($arrMatches[1]);
				} else {
					return null;
				}
			}
		}
	} else {
		// Use fall back method
		if(isset($arrMatches[1]) && !empty($arrMatches[1])){
			return floor ($arrMatches[1]);
		} else {
			return null;
		}
	}
}

echo getInternetExplorerVersion($sUA);
?>

OK, this is a good one. Answers in the comments section.

Q: How do you change the visible number of options in a select box when it drops down, not rendered in the DOM, but when it drops down  ?

I've come to the conclusion you can't because of default parameters specified in the Gecko rendering engine. I know that a <select> element has a "size" attribute which you can access through Javascript with {oSelect}.size or use directly in your HTML with something like <select size="25"></select>, but that changes the number of options visible when the DOM is rendered and not on the drop down event.

For once I think IE and the Trident engine has an advantage over FF and Gecko. IE naturally defaults to display the TOTAL number of <option> items on drop down where as FF is limited to 20, then you have to scroll.

I spent some time looking through the MDC reference manuals, for an interface, some sort of API reference, but the HTML Select Element Interface seems to be limited to the usual foray of methods and properties.

I thought maybe with the introduction of Gecko 1.9 (FF3) and Javascript 1.8 that there might be some interface for changing the default, but wading through documentation there appears not.

So my answer to the question, at the moment is no, but I will be making a suggestion to Mozilla !

... another Microsoft 'feature'. This time though it's proved pretty useful and at a quick glance looks to be a pretty powerful language subset. To quote the Wiki "... (HTCs) are a nonstandard mechanism to implement components in script as Dynamic HTML (DHTML) "behaviors" in the "Microsoft Internet Explorer" web browser..."

For most people like me HTC has probably been limited to Angus Turnball's most excellent IE PNG Fix helping millions solve that annoying CSS problem of no alpha transparency support for PNG's in older versions of IE.

Whilst doing a favor for a friend and giving his website some spit and polish I decided to utilize PNG's alot to achieve some nice 'Apple-esk' aesthetics. Naturally this could potentially lead to some head-splitting CSS issues, but thanks to the PNG fix wonder fix it's a cake walk. Anyway, as these things do, it started me on an internet surfing tangent to try and find out a little about the humble HTC file.

Basically it's a bunch of script that can be executed as a component when assigned to the DOM and there are several ways of assigning it. By adding a 'behaviour'. Typically this is in the form of Microsoft's behaviour: CSS attribute. i.e. <LI STYLE="behavior:url(hilite.htc)">Foo Bar</LI>, which gets me thinking; who came up with Foo Bar !?

BUT, there are other ways of implementing behaviours. Using Javascript is another example (admitedly this is a Microsoft JS feature only, but seeing how this only affects IE anyway !). addBehavior(); and there a bunchof other features too. Much like Microsoft DXImage filters though progid:DXImageTransform.Microsoft.Alpha(sProperties) it will probably fall by the wayside, used only on occasion to, ironically, correct non-standard CSS rendering issues in IE

.