<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Otaqui.Com &#187; javascript</title>
	<atom:link href="http://otaqui.com/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://otaqui.com/blog</link>
	<description>Pete Otaqui's blog about web development and everything else</description>
	<lastBuildDate>Wed, 23 Jun 2010 09:55:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>BBC Fisheye Greasemonkey Script</title>
		<link>http://otaqui.com/blog/646/bbc-fisheye-greasemonkey-script/</link>
		<comments>http://otaqui.com/blog/646/bbc-fisheye-greasemonkey-script/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 09:15:08 +0000</pubDate>
		<dc:creator>pete</dc:creator>
				<category><![CDATA[Professional]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://otaqui.com/blog/?p=646</guid>
		<description><![CDATA[Greasemonkey script to reformat &#8220;Author&#8221; select elements on the BBC&#8217;s Fisheye repository browser, which are ridiculously long (because they contain a considerable chunk of certificate data) which messes with the whole page layout. Shrinking the selects to a more reasonable width fixes this and makes the site more usable. http://otaqui.com/code/bbc-fisheye/bbc-fisheye.user.js // ==UserScript== // @name BBC [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.greasespot.net/">Greasemonkey</a> script to reformat &#8220;Author&#8221; select elements on the BBC&#8217;s Fisheye repository browser, which are ridiculously long (because they contain a considerable chunk of certificate data) which messes with the whole page layout.  Shrinking the selects to a more reasonable width fixes this and makes the site more usable.</p>
<p><a href="http://otaqui.com/code/bbc-fisheye/bbc-fisheye.user.js">http://otaqui.com/code/bbc-fisheye/bbc-fisheye.user.js</a></p>
<pre class="brush: javascript">
// ==UserScript==
// @name           BBC FishEye
// @namespace      http://otaqui.com/code/bbc-fisheye
// @description    Make BBC&#039;s Fisheye look more like it should
// @include        https://fisheye.dev.bbc.co.uk/*
// ==/UserScript==
var elems = document.evaluate(
    &#039;//select[@name=&quot;wbauthor&quot;]&#039;,
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null
);
var i=0;
var sel;
while ( sel = elems.snapshotItem(i++) ) sel.style.width = &#039;200px&#039;;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://otaqui.com/blog/646/bbc-fisheye-greasemonkey-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix The &#8220;For Attribute Resets Focus on Select Tag&#8221; Bug In Internet Explorer using Prototype</title>
		<link>http://otaqui.com/blog/435/fix-the-for-attribute-resets-focus-on-select-tag-bug-in-internet-explorer-using-prototype/</link>
		<comments>http://otaqui.com/blog/435/fix-the-for-attribute-resets-focus-on-select-tag-bug-in-internet-explorer-using-prototype/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 10:20:36 +0000</pubDate>
		<dc:creator>pete</dc:creator>
				<category><![CDATA[Professional]]></category>
		<category><![CDATA[internet-explorer]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://otaqui.com/blog/?p=435</guid>
		<description><![CDATA[Browser sniffing is bad, or so the logic goes. There are occasions though where it makes perfect sense &#8211; for example where you are fixing a known bug in a specific version of a browser. A good example is the bug in IE 6 that resets the selected index of a Select tag that has [...]]]></description>
			<content:encoded><![CDATA[<p>Browser sniffing is <em>bad</em>, or so the logic goes.</p>
<p>There are occasions though where it makes perfect sense &#8211; for example where you are fixing a known bug in a specific version of a browser.  A good example is the bug in IE 6 that resets the selected index of a Select tag that has a label and the for attribute.  This bug doesn&#8217;t affect IE 7 or 8, or any other browser, but does make for a bad user experience if you are doing the right thing and including labels for your select tags.</p>
<p>Microsoft has <a href="http://support.microsoft.com/kb/314279">published some javascript to fix this</a> and I adapted their code to work with with the <a href="http://prototypejs.org">Prototype Javascript Library</a>.</p>
<p>This fix will look for all select tags on the page (you could adapt it to only look for those with the &#8220;for&#8221; attribute but I have a sneaking suspicion that if anything that would in fact be a bit slower) and observe the onfocusin and onfocus events as suggested in the knowledge base article.</p>
<pre class="brush: javascript">
// Select with &#039;for&#039; attribute fix for IE
Event.observe(window,&#039;load&#039;,function() {
	if ( !Prototype.Browser.IE || !(parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf(&quot;MSIE&quot;)+5))==6) ) return;
	$$(&#039;select&#039;).each(function(eSelect) {
		eSelect.observe(&#039;focusin&#039;,function(e) {
			try {
				var eSrc = window.event.srcElement;
				if ( eSrc ) eSrc.tmpIndex = eSrc.selectedIndex;
			} catch(e) {}
		});
		eSelect.observe(&#039;focus&#039;,function(e) {
			try {
				var eSrc = window.event.srcElement;
				if ( eSrc ) eSrc.selectedIndex = eSrc.tmpIndex;
			} catch(e) {}
		})
	});
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://otaqui.com/blog/435/fix-the-for-attribute-resets-focus-on-select-tag-bug-in-internet-explorer-using-prototype/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
