<?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>Blog Standard Stuff &#187; Scripting</title>
	<atom:link href="http://lloydi.com/blog/category/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://lloydi.com/blog</link>
	<description>Nothing to do with standards, even less to do with wombats, only vaguely a blog</description>
	<lastBuildDate>Thu, 05 Feb 2009 00:23:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Another one to add to the list</title>
		<link>http://lloydi.com/blog/2006/10/25/magnolia-login-breaking/</link>
		<comments>http://lloydi.com/blog/2006/10/25/magnolia-login-breaking/#comments</comments>
		<pubDate>Wed, 25 Oct 2006 09:17:04 +0000</pubDate>
		<dc:creator>Lloydi</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://lloydi.com/blog/2006/10/25/magnolia-login-breaking/</guid>
		<description><![CDATA[It&#8217;s happened again &#8230;
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.webstandards.org/2006/10/25/using-a-sledgehammer-to-crack-a-nut/">It&#8217;s happened again &#8230;<br /><img id="image232" src="http://lloydi.com/blog/wp-content/uploads/2006/10/magnolia.jpg" alt="magnolia login" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://lloydi.com/blog/2006/10/25/magnolia-login-breaking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New favelet &#8211; Show all the id attributes used on a page</title>
		<link>http://lloydi.com/blog/2006/09/27/show-ids-used-on-page/</link>
		<comments>http://lloydi.com/blog/2006/09/27/show-ids-used-on-page/#comments</comments>
		<pubDate>Wed, 27 Sep 2006 10:57:50 +0000</pubDate>
		<dc:creator>Lloydi</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://lloydi.com/blog/2006/09/27/show-ids-used-on-page/</guid>
		<description><![CDATA[I was trying to write a little favelet that loops through a bunch of HTML elements on any page and finds all the id values. Once it&#8217;s done, it inserts it into the start of the page for info. Why am I doing this? I wanted to get some stats about what ids we use [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to write a little favelet that loops through a bunch of HTML elements on any page and finds all the id values. Once it&#8217;s done, it inserts it into the start of the page for info. Why am I doing this? I wanted to get some stats about what ids we use on our own sites (ie, do we always call the main nav &#8216;nav&#8217;, &#8216;mainnav&#8217;, &#8216;nav_main&#8217; or something else?) and a favelet seemed like the way to do it. The test page is here:</p>
<p><a id="p197" href="http://lloydi.com/blog/wp-content/uploads/2006/09/favelet-test-page.htm" title="Favelet test page">Favelet test page</a></p>
<p>Thanks to <a href="http://simon.incutio.com/">Simon</a> who sorted out a bug for me (it req&#8217;d an anonymous function that I&#8217;d ommitted). It now works a treat in Firefox. I can&#8217;t be arsed to make it work for anything else, but you&#8217;re more than welcome to have a go :-D Also, any other comments to make it work better are appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://lloydi.com/blog/2006/09/27/show-ids-used-on-page/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Removing annoying CSS borders on Checkboxes and Radio buttons</title>
		<link>http://lloydi.com/blog/2006/08/30/remove-css-borders-radio-checkboxes/</link>
		<comments>http://lloydi.com/blog/2006/08/30/remove-css-borders-radio-checkboxes/#comments</comments>
		<pubDate>Wed, 30 Aug 2006 11:06:19 +0000</pubDate>
		<dc:creator>Lloydi</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://lloydi.com/blog/2006/08/30/removing-annoying-css-borders-on-checkboxes-and-radio-buttons/</guid>
		<description><![CDATA[So, this is one of those caring, sharing geeky posts. When you apply borders to text inputs in CSS (to remove those bevelled edges you get by default) using input {border:1px solid gray;} &#8230; or whatever, it always messes up radio buttons and checkboxes.
One solution is to use attribute selectors, like so: input [type="text"] {border:1px [...]]]></description>
			<content:encoded><![CDATA[<p>So, this is one of those caring, sharing geeky posts. When you apply borders to text inputs in CSS (to remove those bevelled edges you get by default) using <code>input {border:1px solid gray;}</code> &#8230; or whatever, it always messes up radio buttons and checkboxes.</p>
<p>One solution is to use attribute selectors, like so: <code>input [type="text"] {border:1px solid gray;}</code> but IE doesn&#8217;t understand that concept, so you&#8217;re nback to square one. Well, unless you use the power of the DOM (cue dramatic drum roll). So here&#8217;s a little script that takes care of things for you:</p>
<pre>function addEvent(elm, evType, fn, useCapture)
{
if(elm.addEventListener)
  {
  elm.addEventListener(evType, fn, useCapture);
  return true;
  }
else if (elm.attachEvent)
  {
  var r = elm.attachEvent(\'on\' + evType, fn);
  return r;
  }
else
  {
  elm[\'on\' + evType] = fn;
  }
}

// removes the square border that IE
// insists on adding to checkboxes and radio
function removeCheckBoxBorders()
{
var el = document.getElementsByTagName(\&quot;input\&quot;);
for (i=0;i&lt;el.length;i++)
  {
  var type = el[i].getAttribute(\&quot;type\&quot;);
  if((type==\&quot;checkbox\&quot;)||(type==\&quot;radio\&quot;))
    {
   el[i].style.border = \&quot;none\&quot;;
    }
  }
}

addEvent(window, \'load\', removeCheckBoxBorders, false);</pre>
<p>If you like this idea, <a href="http://digg.com/submit?phase=2&#038;url=http://lloydi.com/blog/2006/08/30/remove-css-borders-radio-checkboxes/">why not Digg it</a> (or whatever else it is you cool kids do these days)?</p>
]]></content:encoded>
			<wfw:commentRss>http://lloydi.com/blog/2006/08/30/remove-css-borders-radio-checkboxes/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Improved Style Switching through Dom Scripting</title>
		<link>http://lloydi.com/blog/2006/07/04/style-switching-with-dom-scripting/</link>
		<comments>http://lloydi.com/blog/2006/07/04/style-switching-with-dom-scripting/#comments</comments>
		<pubDate>Tue, 04 Jul 2006 22:39:20 +0000</pubDate>
		<dc:creator>Lloydi</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://lloydi.com/blog/2006/07/04/style-switching-with-dom-scripting/</guid>
		<description><![CDATA[I recently picked up a copy of Professional CSS &#8211; aka &#34;the Where&#8217;s Durstan book&#34; &#8211;  somewhat overdue, it should be noted! I was having a read through the chapter regarding style switching and found myself wanting to tweak the code I was looking at. What was wrong with the code/markup? Actually, nothing major, [...]]]></description>
			<content:encoded><![CDATA[<p>I recently picked up a copy of <a href="http://tinyurl.com/ovkhd">Professional CSS</a> &#8211; aka &quot;<a href="http://www.google.co.uk/search?q=where%27s+durstan">the Where&#8217;s Durstan book</a>&quot; &#8211;  somewhat overdue, it should be noted! I was having a read through the chapter regarding style switching and found myself wanting to tweak the code I was looking at. What was wrong with the code/markup? Actually, nothing major, to be honest. The code worked jus&#8217; fine but what niggled me was that while JavaScript was being used to store set the preferred style (and store a cookie to remember that selection), the links on the page that triggered the style switcher code were written in plain ole HTML with onclick event handlers. These days, whenever I see that sort of thing I just want to take them out and replace with an unobtrusive alternative. </p>
<p>So, that&#8217;s what I did. </p>
<p>Here, then, is my take on the style switcher doohicky. My aims were as follows:</p>
<ul>
<li>If you changed the (alternate) styles associated with the page, it should not be necessary to also  change the switcher links. I thought it would be great if the script automatically found any available alternate styles and created the links accordingly</li>
<li>Discoverability &#8211; style switcher links may be too subtle (depending on design), so I thought it would be cool if there was an element of prompting, ie, &quot;you&#8217;ve been to the page x amount of times &#8211; wanna give these alternative styles a try?&quot; (Note &#8211; I did think that maybe you should prompt on the first visit but I thought that asking if someone wants to try another style out when they&#8217;ve seen the site for the first time was not really giving them time to decide what they do or don&#8217;t like about the site).</li>
<li>If JavaScript is disabled, the style switcher links should simply not be displayed to the user  </li>
<li>Finally, I wanted the script to be customizable, such that with a couple of variables you could specify where on the the page the switcher should be inserted.</li>
</ul>
<p>So, here&#8217;s the script (at least my additions) but you <a href="http://lloydi.com/experiments/better-style-switching-with-dom-scripting/js.html">really should see it in context</a>. <strong>Note</strong>: the  &not; character means that the line break is displayed here for formatting reasons only (should not be like this in <a href="http://lloydi.com/experiments/better-style-switching-with-dom-scripting/write-switcher-links.js">the actual source code</a>)</p>
<p><code>
<pre>/*
This style switcher enhancement was written by Ian Lloyd (http://lloydi.com/).
The basis for this addition comes from Ethan Marcotte\'s style switcher as
documented in the Wrox book professional CSS.

Feel free to use on your site but please leave comment as-is (adding your
own comments regarding further modifications that you may choose to make.
*/

// VARIABLES - uncomment and customise to suit needs
var ContainerID = \&quot;content\&quot;; //Add the name of the container that you ¬
  want the switcher tool to be written into here
var Position = \&quot;first\&quot;; // If you enable this, the switcher will be  ¬
  inserted as either the first item in the parent container, otherwise  ¬
  it\'ll add as last item
var PromptMessage = \&quot;Did you notice that you can change the display of  ¬
  this site using these links above? [This note will not be displayed  ¬
  after you hit refresh or visit another page]\&quot;;
var promptTrigger = 20; //how many page views until the prompt to check  ¬
  out the other styles appears;
// End variables

function findCSS() {
//check for previous visits to site/page
var visitCount = readCookie(\&quot;visitCount\&quot;);
if ((typeof visitCount==\&quot;undefined\&quot;)||(visitCount==\&quot;NaN\&quot;)){
 visitCount=0;
 }
else{
 visitCount = parseInt(visitCount);
 visitCount+=1;
 }
//log another visit to the page, store in cookie - to be used for prompt mechanism
setCookie(\&quot;visitCount\&quot;, visitCount, 365);

var altCSS = false;//no alternative style sheets found
var CSSlinks = document.getElementsByTagName(\&quot;link\&quot;);
if (CSSlinks.length&gt;0)
 {
 var switcherDiv = document.createElement(\&quot;div\&quot;);
 switcherDiv.setAttribute(\&quot;id\&quot;,\&quot;switcher\&quot;);
 var ul = document.createElement(\&quot;ul\&quot;);

 //write in link to default style
 var defaultLI = document.createElement(\&quot;li\&quot;);
 defaultLI.setAttribute(\&quot;class\&quot;,\&quot;first\&quot;);
 defaultLI.setAttribute(\&quot;className\&quot;,\&quot;first\&quot;);
 var defaultLItext = document.createTextNode(\&quot;Default style\&quot;);
 var defA = document.createElement(\&quot;a\&quot;);
 defA.setAttribute(\&quot;href\&quot;,\&quot;#\&quot;);
 defA.setAttribute(\&quot;title\&quot;,\&quot;default\&quot;);
 defA.onclick = doSwitch;
 defA.appendChild(defaultLItext);
 defaultLI.appendChild(defA);
 ul.appendChild(defaultLI);

 //loop through all CSS links - look for alternate styles
 for (i=0;i&lt;CSSlinks.length;i++) {
  if (CSSlinks[i].rel==\&quot;alternate stylesheet\&quot;) {
   altCSS = true;//there are alternative style sheets here
   var newLI 		= document.createElement(\&quot;li\&quot;);
   var newA		= document.createElement(\&quot;a\&quot;);
   newA.setAttribute(\&quot;href\&quot;,\&quot;#\&quot;);
   newA.setAttribute(\&quot;title\&quot;,CSSlinks[i].title);
   newA.onclick = doSwitch;
   var newLItext 	= document.createTextNode(CSSlinks[i].title);
   newA.appendChild(newLItext);
   newLI.appendChild(newA);
   ul.appendChild(newLI);
   }
  }
 if (altCSS) { //alternate stylesheets were found - add to document
  //add navigation list to switcher container
  switcherDiv.appendChild(ul);
  //add prompt text for *this visit only*
  if (typeof promptTrigger!=\'undefined\') {
   if (visitCount==promptTrigger) {
    var promptP = document.createElement(\&quot;p\&quot;);
    var promptPtext = document.createTextNode(PromptMessage);
    promptP.setAttribute(\&quot;class\&quot;,\&quot;style-switch-prompt\&quot;);
    promptP.setAttribute(\&quot;className\&quot;,\&quot;style-switch-prompt\&quot;);
    promptP.appendChild(promptPtext);
    switcherDiv.appendChild(promptP);
    }
   }
   //what parent container is switcher to go into?
   if (typeof ContainerID!=\'undefined\') {//place in container set in variables
    var container = document.getElementById(ContainerID);
    }
   else {//drop into body of document
    var container = document.getElementsByTagName(\&quot;body\&quot;);
    container = container[0];
    }
   //where in parent container should it go?
   if (typeof Position!=\'undefined\') {
    container.insertBefore(switcherDiv, container.firstChild );
    }
   else {
    container.appendChild(switcherDiv);
    }
   }
  }
}
function doSwitch(e) {
activeCSS(this.title);
return false;
}
addEvent(window,\'load\',findCSS, false);</pre>
<p></code></p>
<p>So, that was the idea &#8211; have a play, <a href="http://lloydi.com/experiments/better-style-switching-with-dom-scripting/js.html">see if it works for you</a> (try disabling javascript, download the .js file yourself, try it out on your own site). Whatever your experiences with this, please do add a comment if you have a suggestion or question.</p>
]]></content:encoded>
			<wfw:commentRss>http://lloydi.com/blog/2006/07/04/style-switching-with-dom-scripting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Print Selective Sections of a Web Page using CSS and DOM Scripting</title>
		<link>http://lloydi.com/blog/2006/03/21/how-to-print-selective-sections-of-a-web-page-using-css-and-dom-scripting-2/</link>
		<comments>http://lloydi.com/blog/2006/03/21/how-to-print-selective-sections-of-a-web-page-using-css-and-dom-scripting-2/#comments</comments>
		<pubDate>Tue, 21 Mar 2006 09:02:25 +0000</pubDate>
		<dc:creator>Lloydi</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://www.lloydi.com/blog/2006/03/21/how-to-print-selective-sections-of-a-web-page-using-css-and-dom-scripting-2/</guid>
		<description><![CDATA[This is an experiment to see if it&#8217;s possible to selectively print sections of a large document usings CSS print styles after the page has loaded without affecting the on-screen display.
Why might you use this? Well, the inspiration came from a page of interest rates from banking and savings products. Customers have often complained that [...]]]></description>
			<content:encoded><![CDATA[<p>This is an experiment to see if it&#8217;s possible to selectively print sections of a large document usings CSS print styles after the page has loaded without affecting the on-screen display.</p>
<p>Why might you use this? Well, the inspiration came from a page of interest rates from banking and savings products. Customers have often complained that the interest rates were split up on different sections &#8211; they wanted everything in one page. But what about those people who only want to print out the section that relates to them? One solution is to build the page using include files with separate printer-friendly pages that are linked to. This solution uses DOM scripting to dynamically apply print CSS styles depending on the link that has been clicked on &#8211; if the user clicks on &#8216;print this section&#8217;, all other sections are set to display none for print. </p>
<p>This technique could be use in </p>
<ul>
<li>FAQs</li>
<li>Product information pages</li>
<li>&#8230; well, wherever you feel it has value </li>
</ul>
<p>This has been tested and works in </p>
<ul>
<li>Windows
<ul>
<li>Firefox 1.5</li>
<li>Netscape 6.2</li>
<li>Netscape 8</li>
<li>Opera 7.0 </li>
<li>Opera 8.5</li>
<li>IE 6</li>
</ul>
</li>
<li>Mac
<ul>
<li>Firefox 1.5</li>
<li>Camino 1.0</li>
<li>Opera 7.54   </li>
</ul>
</li>
</ul>
<h3>Notes:</h3>
<p>The &#8216;print this section&#8217; links are <strong>dynamically</strong> inserted for any section that is marked with the <code>class</code> name of <code>section</code> and are hidden using print CSS. No JavaScript, no see the links!</p>
<p>I have had to double up on the attribute setters in the script so that IE didn&#8217;t get upset. It&#8217;s not perfect, but it works and isn&#8217;t really nasty. No, honestly, it isn&#8217;t ;-)
  </p>
<pre>
<code>el[i].setAttribute(&quot;<strong>className</strong>&quot;,&quot;section print&quot;);
el[i].setAttribute(&quot;<strong>class</strong>&quot;,&quot;section print&quot;);
</code></pre>
<h3><a href="http://lloydi.com/experiments/selective-printing/print_selective_sections.html">View the Example Here &raquo; </a></h3>
<p>And if you like what you see, why not <a href="http://digg.com/submit?phase=2&#038;url=http://www.lloydi.com/blog/2006/03/21/how-to-print-selective-sections-of-a-web-page-using-css-and-dom-scripting-2/">digg it for me</a>? Thanks</p>
<h3>Copy the Code Here</h3>
<p>Get the <a href="http://lloydi.com/experiments/selective-printing/print_sections.js">JavaScript here</a> and the <a href="http://lloydi.com/experiments/selective-printing/print_selective_sections.html">HTML here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lloydi.com/blog/2006/03/21/how-to-print-selective-sections-of-a-web-page-using-css-and-dom-scripting-2/feed/</wfw:commentRss>
		<slash:comments>67</slash:comments>
		</item>
	</channel>
</rss>
