<?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>Electric Fairground &#187; Programming</title>
	<atom:link href="http://www.electricfairground.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.electricfairground.com</link>
	<description>OOOm pa pa, OOOm pa pa . . .</description>
	<lastBuildDate>Sat, 04 Sep 2010 23:39:42 +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>Beware of the &amp; (ampersand) character when parsing XML using PHP&#8217;s SimpleXML</title>
		<link>http://www.electricfairground.com/2009/11/15/beware-of-the-ampersand-character-when-parsing-xml-using-phps-simplexml/</link>
		<comments>http://www.electricfairground.com/2009/11/15/beware-of-the-ampersand-character-when-parsing-xml-using-phps-simplexml/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 18:06:47 +0000</pubDate>
		<dc:creator>Lappa</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ampersand]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[SimpleXML]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://www.electricfairground.com/2009/11/15/beware-of-the-ampersand-character-when-parsing-xml-using-phps-simplexml/</guid>
		<description><![CDATA[<a href="http://www.electricfairground.com/2009/11/15/beware-of-the-ampersand-character-when-parsing-xml-using-phps-simplexml/"><img align="left" hspace="5" width="150" height="150" src="http://www.ElectricFairground.com/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>If you are getting errors like &#8220;parser error : EntityRef: expecting &#8216;;&#8217;&#8221; when trying to parse some XML using SimpleXML, it could be because your XML file or string contains an &#038; character. Do the following to remedy the situation: $correct_xml = str_replace('&#038;','&#38;amp;',$problem_xml);]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.electricfairground.com%2F2009%2F11%2F15%2Fbeware-of-the-ampersand-character-when-parsing-xml-using-phps-simplexml%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.electricfairground.com%2F2009%2F11%2F15%2Fbeware-of-the-ampersand-character-when-parsing-xml-using-phps-simplexml%2F&amp;source=robinspots&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>If you are getting errors like &#8220;parser error : EntityRef: expecting &#8216;;&#8217;&#8221; when trying to parse some XML using SimpleXML, it could be because your XML file or string contains an &#038; character. Do the following to remedy the situation:</p>
<pre class="brush: php">
$correct_xml = str_replace('&#038;','&#38;amp;',$problem_xml);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.electricfairground.com/2009/11/15/beware-of-the-ampersand-character-when-parsing-xml-using-phps-simplexml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajax content, jQuery page transitions and why you should ditch the browser refresh</title>
		<link>http://www.electricfairground.com/2009/10/31/ajax-content-jquery-page-transitions-and-why-you-should-ditch-the-browser-refresh/</link>
		<comments>http://www.electricfairground.com/2009/10/31/ajax-content-jquery-page-transitions-and-why-you-should-ditch-the-browser-refresh/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 16:02:07 +0000</pubDate>
		<dc:creator>Lappa</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.electricfairground.com/?p=72</guid>
		<description><![CDATA[<a href="http://www.electricfairground.com/2009/10/31/ajax-content-jquery-page-transitions-and-why-you-should-ditch-the-browser-refresh/"><img align="left" hspace="5" width="150" height="150" src="http://www.ElectricFairground.com/wp-content/link-trading-prohibited-150x150.gif" class="alignleft wp-post-image tfe" alt="no browser refresh" title="no browser refresh" /></a>I’ve just finished a project I’ve been working on over the last couple of months that was a jQuery-based ajax application without page refreshes. I thought I’d take this opportunity to share some of the problems I encountered whilst they were still fresh in my mind. If you’re thinking of making your own jQuery online [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.electricfairground.com%2F2009%2F10%2F31%2Fajax-content-jquery-page-transitions-and-why-you-should-ditch-the-browser-refresh%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.electricfairground.com%2F2009%2F10%2F31%2Fajax-content-jquery-page-transitions-and-why-you-should-ditch-the-browser-refresh%2F&amp;source=robinspots&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<div id="attachment_73" class="wp-caption alignnone" style="width: 363px"><img class="size-full wp-image-73" title="no browser refresh" src="http://www.ElectricFairground.com/wp-content/link-trading-prohibited.gif" alt="no browser refresh" width="353" height="261" /><p class="wp-caption-text">Down with the browser refresh</p></div>
<p>I’ve just finished a project I’ve been working on over the last couple of months that was a jQuery-based ajax application without page refreshes. I thought I’d take this opportunity to share some of the problems I encountered whilst they were still fresh in my mind.</p>
<p>If you’re thinking of making your own jQuery online app I’d recommend trying out the ‘no refresh’ method. Once you’ve got it working, you’ll wonder how you’ve managed to cope so long with all these page refreshes, and each time somebody else’s site forces your browser to refresh, you’ll throw up a bit in your mouth.</p>
<p>In my humble opinion, asynchronous data transfer is the future and soon it will be very unusual to have your page refresh every time you want to see new content. Browser refreshes are clunky, ugly are an unnecessary interruption to the user experience flow.</p>
<p>With jQuery and ajax ruling your content you can have:</p>
<p><span id="more-72"></span></p>
<ul>
<li>Complete control over the user experience. While your user is waiting for a page to load, you can display a fancy loading graphic, or even a small film clip, or some music, or whatever you like. It makes for a much smoother page transition, which should have it’s own bullet . .</li>
<li>Smooth page transitions. Okay, this is part of the user experience too, but such an important part I thought it deserved a special mention. Instead of content loading, then appearing in drips and drabs as and when it finishes, you can display your loading graphic until the whole page is ready, and then use a pretty jQuery effect to display the new content. You can have the page slide in, gradually fade in or just appear, the point is the page is ready instantly, and the user is aware that they can now click on things and type.</li>
</ul>
<p>“But what about all the disadvantages!?” I hear you cry. Well, yes, you’re right there are problems too, but I’m going to try and address these with solutions and workarounds I’ve been using.</p>
<p><img src="http://www.oucs.ox.ac.uk/rts/xaira/Doc/images/browser01.jpg" alt="xml in a browser" /></p>
<h2>Problem #1 &#8211; You click on a link and your browser takes you straight to the content, but refreshes the page in the process. Bad browser! Bad!</h2>
<p>If you’re building an ajax app, this is a big nono. Especially since it’s most likely that that page will have no layout, and just be some JSON/XML data.</p>
<p>The solution is to use a jQuery event handler to intercept the link and make it do what you want, overriding the default behaviour.</p>
<p>Tip: For my application, I added classes to each link element such as a.internal and a.external to distinguish between the two. If you don’t do this, external links will be loaded in your application instead of in a new tab/page. You can also add separate behaviour for external links then, such as displaying a popup informing the user they are leaving your site.</p>
<pre class='brush: js'>

$('a.internal').live('click',function() {
var post_url = $(this).attr('href');
$.historyLoad(post_url);
return false;
});
</pre>
<p>This bit of jQuery should go in the $(document).ready section of your code. It intercepts all links clicked of which have the class &#8216;internal&#8217;, sends their &#8216;href&#8217; attribute to the historyLoad function, and then returns false to prevent the link from opening a new page.</p>
<p>But that&#8217;s not the only problem you&#8217;re likely to encounter.</p>
<div class="wp-caption alignnone" style="width: 809px"><img title="Empty browser" src="http://img198.imageshack.us/img198/6195/26821035.jpg" alt="empty browser" width="799" height="624" /><p class="wp-caption-text">empty browser</p></div>
<h2>Problem #2 &#8211; You scroll halfway down the page, click on a link and the content loads above the point your looking at.</h2>
<p>If you’re displaying a lot of content, that requires vertical scrolling, you might find that when you click on a link to a page displayer less content, this content gets injected above the browser’s viewport. In other words, the new page is shorter than the old one and you need to scroll up to view it.</p>
<p>If you’ve never heard of ajax or jQuery before, you’re probably not going to realise that simply scrolling up will solve this one, so it’s good practice to cater for these people.</p>
<p>There is a simple solution to this. Add the following code to your ajax ‘success’ function &#8211; the function that gets called when your ajax call returns with some data.</p>
<pre class='brush: js'>

$('html, body').animate({scrollTop:0}, 'fast');
</pre>
<p>This will take the user back to the top of the page before the new content is injected.</p>
<h2>
<div class="wp-caption alignnone" style="width: 810px"><img title="Start from the beginning" src="http://www.lookerslandrover.co.uk/live/images/cme_resources/Public/Sign-Posts.jpg" alt="Start again from the beginning" width="800" height="536" /><p class="wp-caption-text">Start again from the beginning</p></div></h2>
<h2>Problem #3 &#8211; going straight to a page deep in your application’s navigation structure.</h2>
<p>So, you want to load up a bookmark you have from an article you read on the site six months ago? But wait! It just takes you to the home page and you need to wade through the navigation to get back to this article.</p>
<p>Because the page isn’t refreshing, neither is your browser registering the fact that you’ve changed pages. There is a workaround for this involving adding a unique hash code to the url using a nice little jQuery plugin. <a href="http://www.electricfairground.com/2009/10/01/restoring-conventional-page-navigation-to-your-javascript-application-with-jquery-history-plugin/" target="_blank">Please read my tutorial on the subject</a> for more details, or google ‘jQuery history plugin’.</p>
<p><div class="wp-caption aligncenter" style="width: 380px"><img title="Lorries overtaking" src="http://www.grannybuttons.com/granny_buttons/images/granny_buttons_overtaking_a_truckload_of_straw-thumb.jpg" alt="No room for overtaking here" width="370" height="257" /><p class="wp-caption-text">No room for overtaking here</p></div>
<h2>Problem #4 &#8211; Ajax requests jumping the queue</h2>
<p>I didn&#8217;t encounter this problem for quite a while, but if you&#8217;ve got a page running without refreshes, chances are you&#8217;ll experience the same problem.</p>
<p>In jQuery, there&#8217;s no &#8220;request stack&#8221; or &#8220;request queue&#8221; for ajax. When you send off an ajax request, it comes back after the data you are rquesting has loaded, and only then.</p>
<p>Consider what might happen if you first click on a link for a page with 1000 images listed in one big row, and then get bored of waiting for this to load and click on a link for a single image. When you click on the second link (the one for the single image), it will not cancel the first request. So now you have two requests being processed by your server. Naturally, the single image is going to come back first. Great! That&#8217;s what we wanted. But as soon as the 1000 images have loaded, the &#8216;success&#8217; function will get called and you&#8217;ll find your viewing experience unexpectantly interrupted.</p>
<p>To fix this you need to cancel any previous ajax requests before you initiate a new one. To do this, first declare a global variable to hold the details of any ajax requests your application will make:</p>
<pre class='brush: js'>

var ajax_request = null;
</pre>
<p>This makes a variable that we can reference lateron to see if an ajax request is under way. Once we&#8217;ve got this we can create our ajax request:</p>
<pre class='brush: js'>

if (ajax_request) { // checks for an existing ajax request
ajax_request.abort(); // aborts request
}
ajax_request = $.ajax({ // start the AJAX request
type: "POST", // I'm sending it via POST, you can use GET if you're feeling dangerous
url: post_url, // the URL we are retrieving
data: null, // in this case we are not sending any data
success: function(data) { // execute the below if the AJAX goes according to plan
//alert("success!");

// you can now inject the ajax response into any element you like witht the 'data' variable

});
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) { // execute this if it all goes tits up
alert(textStatus + errorThrown);
return false;
}
});
</pre>
<p>In this example, the ajax request will be sent regardless, but jQuery will cancel any previous requests, to avoid the requests overtaking eachother.</p>
<p>Tip: If you would like more complex queue behaviour it might be worth checking out the<a href="http://plugins.jquery.com/project/ajaxqueue" target="_blank"> jQuery Ajax Queue plugin</a>.</p>
<p>Do you think this is all bullshit? That the browser refresh is here to stay? Or have you encountered other problems when ajaxifying your own website?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.electricfairground.com/2009/10/31/ajax-content-jquery-page-transitions-and-why-you-should-ditch-the-browser-refresh/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Restoring conventional page navigation to your javascript application with jQuery history plugin</title>
		<link>http://www.electricfairground.com/2009/10/01/restoring-conventional-page-navigation-to-your-javascript-application-with-jquery-history-plugin/</link>
		<comments>http://www.electricfairground.com/2009/10/01/restoring-conventional-page-navigation-to-your-javascript-application-with-jquery-history-plugin/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 19:56:03 +0000</pubDate>
		<dc:creator>Lappa</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.electricfairground.com/?p=61</guid>
		<description><![CDATA[<a href="http://www.electricfairground.com/2009/10/01/restoring-conventional-page-navigation-to-your-javascript-application-with-jquery-history-plugin/"><img align="left" hspace="5" width="150" height="150" src="http://www.ElectricFairground.com/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>I&#8217;m not sure how, but my jQuery application suddenly got very complicated. One minute I was adding cool onmouseover effects and then BANG I&#8217;m inserting new elements all over the place and I have to look into heavy compression just to get the thing to download this side of the apocalypse. Browsing through my application [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.electricfairground.com%2F2009%2F10%2F01%2Frestoring-conventional-page-navigation-to-your-javascript-application-with-jquery-history-plugin%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.electricfairground.com%2F2009%2F10%2F01%2Frestoring-conventional-page-navigation-to-your-javascript-application-with-jquery-history-plugin%2F&amp;source=robinspots&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;m not sure how, but my jQuery application suddenly got very complicated. One minute I was adding cool onmouseover effects and then BANG I&#8217;m inserting new elements all over the place and I have to look into heavy compression just to get the thing to download this side of the apocalypse.</p>
<p>Browsing through my application is a breeze. All the links are rewired to AJAX requests with smooth transitions and lots of slideUp-and-downs. There&#8217;s one glaring hole that might just bring this happy user experience down quicker than a Lehman brother wearing Iron Boots.</p>
<p>Whenever my lovely users click &#8216;back&#8217; on their browser they get taken back to the obscenity that is the non-standards-compliant flashing gif-ridden site they came from, not the last thing they were viewing on my site. And if he or she clicks ‘refresh’ the application state goes back to the original and my user has to navigate back to the page he or she was viewing all over again. What a knightmare.</p>
<p>The browser navigation controls &#8211; back, forwards and refresh &#8211; are a staple of any user&#8217;s experience. Of course, being a web developer you will recognise the lack of page refreshes and the changing of page elements and automatically look for site-specific navigation links on the page itself. However, your average user is going to get very confused, thinking their browser buttons are broken or worse &#8211; your website is broken.</p>
<p>And it&#8217;s not only the user that&#8217;s going to encounter problems. If a Google Spider can’t see pages with unique URLs it’s not going to index them. So all I’m going to get on a Google search is whatever is on the landing page, which is just header information and a footer &#8211; not very useful. If my user wants to bookmark a page for later, he or she is going to have to start again, before all the AJAX fun began. The list goes on. It&#8217;s like building a vast palace with turrets and different wings but neglecting to build any doors. Your guests are going to walk over the drawbridge and marvel at the splendour of your architecture, the complete set of Power Ranger themed bedrooms, yet have no idea how to get there.</p>
<p>Anyway, here&#8217;s how I solved it:</p>
<p><span id="more-61"></span></p>
<h2>Step 1: jQuery history plugin</h2>
<p>First of all, I downloaded the <a href="http://www.mikage.to/jquery/jquery_history.html">Mikage’s jQuery history plugin</a>. This is a bit of code that allows me to write to my browser’s history using a hash key. This hash can be pretty much anything that can uniquely describe your application&#8217;s state. I chose to make it the same as the resource I was loading into the main part of my application. So the plugin would add &#8216;www.mysite.com/page1#page2&#8242; to my browser history when I clicked on the &#8216;Page 2&#8242; link. Once I’d saved the plugin to my computer, I put this line in my head section of page1.html.</p>
<pre class='brush: js'>

&lt;script src='http://www.mysite.com/js/jquery.history.js' type='text/javascript'&gt;&lt;/script&gt;
</pre>
<p>Now that jQuery knows I want to use this plugin, I need to initialise before I can start using it. I put this line just below the previous line, also in the $(document.ready()) section.</p>
<pre class='brush: js'>
$(document).ready(function() {

$.historyInit(ajaxRender, 'http://www.mysite.com/page1');
};
</pre>
<p>Right, now it’s ready to use.</p>
<h2>Step 2: The click event</h2>
<p>Thinking about it, the page state always changes directly after the user clicks on a link (as it would on any other site I guess). So each of these state changes is tied to an &lt;a&gt; element. Therefore, I’m going to use jQuery’s live() function to tie a function to each link element’s ‘click’ event. So every time a user clicks a link some code will get executed. I used the live() function instead of the more common click() event handler because live() ties all future instances of an element to the function instead of just the ones initially in the DOM. This means I can happily insert new &#8216;a&#8217; elements knowing that they’ll still respond in the same way. Here’s the click event code (this should also go in the $(document).ready so that it&#8217;s ready when the page loads):</p>
<pre class='brush: js'>

$('a.internal').live('click',function() {
var post_url = $(this).attr('href');
//alert(post_url);
$.historyLoad(post_url);
return false;
});
</pre>
<p>You can see that I&#8217;m binding this function to the click events for each &#8216;a.internal&#8217; element. I&#8217;ve given each internal link this class so that I can differentiate between internal and external links. If all links were treated the same, I&#8217;d get google.com loading inside my homepage. I extract the ‘href’ part of the link so that I know where the link is pointing. This is then assigned to the variable ‘post_url’. Then I call the historyLoad() method. This tells the jQuery plugin I just set up to add a new page to the browser history. It does this by adding a hash key to the end of the url. For example www.mysite.com/page1 would become www.mysite.com/page1#page2 in the address bar, and my application would then go about rendering the page2 on my page to reflect the change. The ‘return false;’ line is important, as this stops the browser executing it’s normal event handling for the element. If I didn’t include this line, all would be lost, as the browser would merrily redirect us to page2.html (thinking it was a regular link) and page1 would be lost to the wind.</p>
<h2>Step 3: Rendering the page</h2>
<p>Once historyLoad() has done it’s job and added a page to the browser history, it will then follow a callback function that we defined earlier with historyInit(). The callback function renderPage() is going to run the AJAX request and insert the new data into my page. The code for this is as follows (this can go anywhere in your javascript code):</p>
<pre class='brush: js'>

function ajaxRender(post_url) {
$('body').css('cursor','wait'); // changes the cursor to a wait symbol
if($.browser.msie) { // if the browser is Internet Explorer
// jquery's $.load() function does't work when hash include special characters like åäö.
post_url = encodeURIComponent(post_url); // removes special characters
}
if (post_url) { // checks that a URL is present
$.ajax({ // start the AJAX request
type: 'POST', // I'm sending it via POST, you can use GET if you're feeling dangerous
url: post_url, // the URL we are retrieving
data: null, // in this case we are not sending any data
success: function(data) { // execute the below if the AJAX goes according to plan
$('#page_content').html(data); // put the data retrieved from the AJAX request into the div container
$('body').css('cursor','default'); // put the cursor back to normal
},
error: function (XMLHttpRequest, textStatus, errorThrown) { // execute this if it all goes tits up
$('body').css('cursor','default');
alert(textStatus + errorThrown);
return false;
}
});
} else { // if there is no post_url, i.e. it's the home page
$('body').css('cursor','default'); // put the cursor back to normal
}
};
</pre>
<p>This function executes the AJAX request and puts the data it retrieves into the #page_content div.</p>
<p>Once you&#8217;ve got these three components in your code you should be OK.</p>
<p>Note: If you’re just loading stuff from a file and not sending data it would be a better idea to use jQuery’s load() method.</p>
<p>Feel free to comment if there&#8217;s a bit you don&#8217;t understand or are having trouble with.</p>
<p>Edit: I just discovered that this process is called &#8216;deep linking&#8217;. Sounds like a bit of a serious term, but it is much shorter than &#8216;the restoration of conventional page navigation to an AJAX application&#8217;. Had I known this before I wrote this post I probably would&#8217;ve looked into using the <a href="http://www.asual.com/jquery/address/">jQuery Address deep linking plugin</a> instead. But my method worked fine for me . . .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.electricfairground.com/2009/10/01/restoring-conventional-page-navigation-to-your-javascript-application-with-jquery-history-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Image map rollover effects using jQuery&#8217;s MapHilight plugin</title>
		<link>http://www.electricfairground.com/2009/08/08/image-map-rollover-effects-using-jquerys-maphilight-plugin/</link>
		<comments>http://www.electricfairground.com/2009/08/08/image-map-rollover-effects-using-jquerys-maphilight-plugin/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 12:15:49 +0000</pubDate>
		<dc:creator>Lappa</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[Inkscape]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[maphilight]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[polygon]]></category>
		<category><![CDATA[rollover]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.electricfairground.com/?p=47</guid>
		<description><![CDATA[<a href="http://www.electricfairground.com/2009/08/08/image-map-rollover-effects-using-jquerys-maphilight-plugin/"><img align="left" hspace="5" width="150" src="http://www.electricfairground.com/img/maphilight_post/grey_map.png" class="alignleft wp-post-image tfe" alt="" title="Grey map of Europe" /></a>Update: you can see the finished version of my map here. So I want to make a big map of europe that hilights the different countries when you move your mouse over them. Initially I thought this would be really easy using a bit of CSS and :hover . . . . no dice. But [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.electricfairground.com%2F2009%2F08%2F08%2Fimage-map-rollover-effects-using-jquerys-maphilight-plugin%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.electricfairground.com%2F2009%2F08%2F08%2Fimage-map-rollover-effects-using-jquerys-maphilight-plugin%2F&amp;source=robinspots&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p><span style="color: #ff6600;">Update: you can see the finished version of my map <a href="http://www.workingineuropeandasia.com/?u=1c6a6f942368d690c3cba37b7b0eef6a">here</a>.</span></p>
<p>So I want to make a big map of europe that hilights the different countries when you move your mouse over them. Initially I thought this would be really easy using a bit of CSS and :hover . . . . no dice. But to my surprise I found out that it&#8217;s possible to use an ordinary HTML image map to define some pretty complex shapes, and let&#8217;s face it, shapes don&#8217;t get much more complex than this.</p>
<p>OK, so it&#8217;s possible to create clickable areas in HTML using an image map, but how do I add rollover effects to this? CSS didn&#8217;t seem to work so my next port of call was the wonderful jQuery. I found a plugin call <a href="http://plugins.jquery.com/project/maphilight">mapHilight</a> that takes an HTML image map, and adds some javascript hilighting wizardry to it. You can see a really cool example using a <a href="http://davidlynch.org/js/maphilight/docs/demo_usa.html">map of the states</a>, this is almost exactly what I want but for Europe. I&#8217;m going to try and record everything I do, in the hope that someone else might find this useful, so here goes.</p>
<p><span id="more-47"></span></p>
<h2>Step 1: Your image</h2>
<p>First of all, you need to prepare the source image. In this example I&#8217;m going to be using a map of europe (see below).</p>
<p><a href="http://www.electricfairground.com/img/maphilight_post/grey_map.png"><img class="alignnone" title="Grey map of Europe" src="http://www.electricfairground.com/img/maphilight_post/grey_map.png" alt="" width="340" height="351" /></a></p>
<h2>Step 2: HTML Image Maps</h2>
<p>Now that I have my image ready, I need to work out how to get the computer to recognise the individual areas. For my map each country is separated from other bordering countries by a white line, your image might not be so defined, in which case you should probably open the image up in Photoshop or something and separate the sections to make it easier.</p>
<p>I did a bit of research on Google and came across something quite interesting. Built into HTML there are &lt;map&gt; and &lt;shape&gt; tags. These are used to define image maps like the one I&#8217;m trying to make. An example of an HTML image map is this:</p>
<pre class="brush: js">
<map name="testMap">
<area id="box" shape="polygon" coords="20,20,106,20,106,106,20,106" href="http://www.stackoverflow.com" />
<area id="triangle" shape="polygon" coords="216,50,339,50,277,156" href="http://www.google.com" />
<area id="bordertriangle" shape="polygon" coords="460,0,574,0,460,220" href="http://www.cnn.com" />
<area id="pentagon" shape="polygon" coords="704,65,769,115,744,196,665,196,640,115" href="http://slashdot.org" />
</map>
</pre>
<p>Here you can see four areas within a map. In this example each area is set as shape=&#8217;polygon&#8217;. This is because these shapes are complex and can&#8217;t be defined in simpler terms. However, if your image map is not so complicated, you could try using shape=&#8217;rect&#8217; or shape=&#8217;circle&#8217;.</p>
<ul>
<li><a href="http://www.javascriptkit.com/howto/imagemap.shtml">More information on Creating HTML Image Maps</a></li>
</ul>
<p>OK, so I know that the shape of each country on my map can probably be defined as a list of points (like a join-the-dots puzzle). I&#8217;m not sure exactly what the numbers will mean, but I guess they&#8217;re just coordinates on a fictional grid slapped on top of my image.</p>
<p>Next question: How do I get these coordinates for my own image?</p>
<h2>Step 3: Download Inkscape</h2>
<p>Well after a bit more digging I found an App called <a href="http://www.inkscape.org/index.php?lang=en">Inkscape</a>.</p>
<p><a href="http://www.inkscape.org/download/?lang=en">Download Inkscape (free)</a></p>
<p>I think you can probably use some other apps too, like Illistrator or something else, but I don&#8217;t have the kind of money to splash out on such overpriced tripe, so I&#8217;ll be using Inkscape.</p>
<p>Right, while that&#8217;s downloading I&#8217;ll explain why I think Inkscape will do the job. To be honest I don&#8217;t really know that much about inkscape. What I do know is that you can open up any image you like and trace the edges. You can then save the image again (in a different format) and this will contain this list of coordinates that I&#8217;m after. Hopefully.</p>
<h2>Step 4: Path Detection in Inkscape</h2>
<p><code>Once you've finished downloading Inkscape you'll need to open it up. Then select File&gt;Open and select the image you are working on.</code></p>
<p>Now here&#8217;s where it gets a bit more complicated. Inkscape is very good at detecting edges, but I found it needed a helping hand to make sure it knew that all of these countries were separate blobs, and not just one big blob. The first time I tried edge detection I managed to get a big polygon, but it was so big that it took up most of mainland europe. What I&#8217;d recommend you do is do a bit of experimentation to see how well Inkscape finds the borders in your image.</p>
<p>To give it a go, click on your image (so that there are black resizing dots around it), then select Path&gt;Trace Bitmap. In the box that pops up, you can either select &#8216;Edge Detection&#8217; or &#8216;Color Quantization&#8217;. As far as I can tell, you should use the first if there are very definitive edges already in the image and the second if the areas you&#8217;re trying to separate are different colours. I first tried &#8216;Edge Detection&#8217; and this wasn&#8217;t really working for me. So I went back to Photoshop and coloured all my countries in different colours, opened Inkscape back up and selected &#8216;Color Quantization&#8217; and it worked much better. Once you&#8217;ve selected your choice click &#8216;Update&#8217; to get a preview of what it will look like and then &#8216;OK&#8217; to start the magic.</p>
<p>Now if it&#8217;s worked, you should see a black line around each of the areas in your image. Inkscape should turn your image into several different shapes all with a black outline. If this doesn&#8217;t happen, or you get shapes in the wrong places, you&#8217;ll have to undo the path detection and try again. Once you&#8217;re happy you can move onto the next step.</p>
<h2>Step 5: HTML Polygonization</h2>
<p>In Inkscape, save the image as a .svg file. This is the format we&#8217;re going to use to extract the path information for our HTML polygon shapes. Open up your SVG file in your favourite text editor and scroll down until you find a list of numbers a bit like this one:</p>
<p>d=&#8221;M 662.5,1204 C 634.39954,1200.1136 558.02119,1154.3401 .. . .. .</p>
<p>Believe it or not, this is your image map. Unfortunately this data is in a format that isn&#8217;t very useful to us. Not only are the shape coordinates shrouded in a mysterious M and C characters, but they are also using lots of decimal places which HTML can&#8217;t understand. To sort this jumble of nonsense I decided to write a bit of Javascript. I call this my <a href="http://www.electricfairground.com/polygonator/index.html">Polygonator</a>. Go there and enter in the numbers and text within the &#8220;s just after d=&#8221;. So your bit of text will start M 662 . . .etc and should end with a single z. Then click &#8216;Process&#8217; and you should be given some HTML code. Hooray!</p>
<p>A word of warning: depending on how acurate you want your area to be you may need to simplify your path a bit. If your SVG files contains millions of coordinates and you want something much simpler, then you can open it back up in Inkscape and select Path&gt;Simplify. Then repeat this step.</p>
<h2>Step 6: Add Your Image Area</h2>
<p>Copy all of this HTML and paste it between the &lt;map&gt; &lt;/map&gt; tags in your webpage. You should now have something that looks a bit like:</p>
<pre class="brush: html">
<map name="testMap">
<area id="shape1" shape="poly" coords="20,20,106,20,106,106,20,106" href="http://www.electricfairground.com" />
</map>
</pre>
<p>If you have more than one line in your SVG file starting with d=&#8221; then you&#8217;ll need to process each of these and convert them one at a time. Just repeat steps 5 and 6 for each of them and you should be OK.</p>
<h2>Step 7: jQuery and mapHilight</h2>
<p>Now we need to tie up the loose ends and get to the jQuery bit. If you haven&#8217;t already included jQuery at the top of your page then put this in your &lt;head&gt; section:</p>
<pre class="brush: php">
&lt; ?= javascript_include_tag('jquery-1.3.2.min.js'); ?&gt;</pre>
<p>Now we need to add the MapHilight jQuery plugin. I don&#8217;t really understand what this plugin does, but it seemed to do wonders for my map, so you should give it a go too.  Download the <a href="http://plugins.jquery.com/project/maphilight">mapHilight plugin</a> and then include it just after you included jQuery.</p>
<pre class="brush: php">
&lt; ?= javascript_include_tag('jquery.maphilight.min.js'); ?&gt;

<script type="text/javascript"><!--mce:0--></script></pre>
<p>The second bit of script just initiates the plugin. It looks for an image with class=&#8217;map&#8217;, so if you&#8217;re using the same code make sure your image has this class. For example:</p>
<pre class="brush: html">
<img usemap="#testMap" src="images/map/grey_map.png" alt="Click on a country to see its profile" /></pre>
<p>You&#8217;ll see my image also has usemap=&#8221;#testMap&#8221;. This is the bit that links the image to the &lt;map&gt;. So make sure you include the name of your map in this bit.</p>
<h2>Good Work Team</h2>
<p>Finished! Now when you look at your page you should see that different sections of your map light up when you move your mouse over them. Let me know if you have any problems and I&#8217;ll do my best to suggest something.</p>
<div style="width: 460px; height: 100%; top: 0px; right: 0px; padding-left: 0px; position: fixed; background-color: white; z-index: 1000; display: none;">
<div style="border: 0px none; top: 1px; width: 100%; height: 42px; position: absolute;">
<form>
<div style="position: absolute; left: 2px; right: 0px;">
<input id="LIU_txt" style="border: 1px solid black; margin: 0pt; padding: 0pt; position: absolute; left: 0px; right: 240px; font-size: 14px ! important; height: 17px ! important; line-height: 50px; display: block;" />
<select id="LIU_sel" style="border: 1px solid black; margin: 0pt; padding: 0pt; position: absolute; width: 100px; right: 138px; font-size: 14px ! important; height: 17px;">
<option style="border: 0pt none; width: 30%; height: 19px;">Wikipedia</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Wictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Chambers (UK)</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google images</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google define</option>
<option style="border: 0pt none; width: 30%; height: 19px;">The Free Dictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Join example</option>
<option style="border: 0pt none; width: 30%; height: 19px;">WordNet</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Urban Dictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Answers.com</option>
<option style="border: 0pt none; width: 30%; height: 19px;">rhymezone.com</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Merriam-Webster</option>
</select>
<input id="LIU_search" style="border: 1px solid black; padding: 0pt; position: absolute; width: 68px; right: 68px; font-size: 14px ! important; height: 19px;" type="submit" value="Search" /><button id="LIU_prev" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 46px; height: 19px;">&lt;</button><button id="LIU_next" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 24px; height: 19px;">&gt;</button><button id="LIU_mode" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 2px; height: 19px;">0</button></div>
<div style="position: absolute; left: 2px; right: 0px; top: 22px;"><button id="LIU_0" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">w</button><button id="LIU_1" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">v</button><button id="LIU_2" style="border-bottom: 1px solid white; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">c</button><button id="LIU_3" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">i</button><button id="LIU_4" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">d</button><button id="LIU_5" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">f</button><button id="LIU_6" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">j</button><button id="LIU_7" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">o</button><button id="LIU_8" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">g</button><button id="LIU_9" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">u</button><button id="LIU_10" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">a</button><button id="LIU_11" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">r</button><button id="LIU_12" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: #dddddd;">m</button></div>
</form>
</div>
</div>
<div style="width: 460px; height: 100%; top: 0px; right: 0px; padding-left: 0px; position: fixed; background-color: white; z-index: 1000; display: none;">
<div style="border: 0px none; top: 1px; width: 100%; height: 42px; position: absolute;">
<form>
<div style="position: absolute; left: 2px; right: 0px;">
<input id="LIU_txt" style="border: 1px solid black; margin: 0pt; padding: 0pt; position: absolute; left: 0px; right: 240px; font-size: 14px ! important; height: 17px ! important; line-height: 50px; display: block;" />
<select id="LIU_sel" style="border: 1px solid black; margin: 0pt; padding: 0pt; position: absolute; width: 100px; right: 138px; font-size: 14px ! important; height: 17px;">
<option style="border: 0pt none; width: 30%; height: 19px;">Wikipedia</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Wictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Chambers (UK)</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google images</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google define</option>
<option style="border: 0pt none; width: 30%; height: 19px;">The Free Dictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Join example</option>
<option style="border: 0pt none; width: 30%; height: 19px;">WordNet</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Urban Dictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Answers.com</option>
<option style="border: 0pt none; width: 30%; height: 19px;">rhymezone.com</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Merriam-Webster</option>
</select>
<input id="LIU_search" style="border: 1px solid black; padding: 0pt; position: absolute; width: 68px; right: 68px; font-size: 14px ! important; height: 19px;" type="submit" value="Search" /><button id="LIU_prev" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 46px; height: 19px;">&lt;</button><button id="LIU_next" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 24px; height: 19px;">&gt;</button><button id="LIU_mode" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 2px; height: 19px;">0</button></div>
<div style="position: absolute; left: 2px; right: 0px; top: 22px;"><button id="LIU_0" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">w</button><button id="LIU_1" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">v</button><button id="LIU_2" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">c</button><button id="LIU_3" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">i</button><button id="LIU_4" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">d</button><button id="LIU_5" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">f</button><button id="LIU_6" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">j</button><button id="LIU_7" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">o</button><button id="LIU_8" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">g</button><button id="LIU_9" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">u</button><button id="LIU_10" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">a</button><button id="LIU_11" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">r</button><button id="LIU_12" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">m</button></div>
</form>
</div>
</div>
<div style="width: 460px; height: 100%; top: 0px; right: 0px; padding-left: 0px; position: fixed; background-color: white; z-index: 1000; display: none;">
<div style="border: 0px none; top: 1px; width: 100%; height: 42px; position: absolute;">
<form>
<div style="position: absolute; left: 2px; right: 0px;">
<input id="LIU_txt" style="border: 1px solid black; margin: 0pt; padding: 0pt; position: absolute; left: 0px; right: 240px; font-size: 14px ! important; height: 17px ! important; line-height: 50px; display: block;" />
<select id="LIU_sel" style="border: 1px solid black; margin: 0pt; padding: 0pt; position: absolute; width: 100px; right: 138px; font-size: 14px ! important; height: 17px;">
<option style="border: 0pt none; width: 30%; height: 19px;">Wikipedia</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Wictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Chambers (UK)</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google images</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google define</option>
<option style="border: 0pt none; width: 30%; height: 19px;">The Free Dictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Join example</option>
<option style="border: 0pt none; width: 30%; height: 19px;">WordNet</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Urban Dictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Answers.com</option>
<option style="border: 0pt none; width: 30%; height: 19px;">rhymezone.com</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Merriam-Webster</option>
</select>
<input id="LIU_search" style="border: 1px solid black; padding: 0pt; position: absolute; width: 68px; right: 68px; font-size: 14px ! important; height: 19px;" type="submit" value="Search" /><button id="LIU_prev" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 46px; height: 19px;">&lt;</button><button id="LIU_next" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 24px; height: 19px;">&gt;</button><button id="LIU_mode" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 2px; height: 19px;">0</button></div>
<div style="position: absolute; left: 2px; right: 0px; top: 22px;"><button id="LIU_0" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">w</button><button id="LIU_1" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">v</button><button id="LIU_2" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">c</button><button id="LIU_3" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">i</button><button id="LIU_4" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">d</button><button id="LIU_5" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">f</button><button id="LIU_6" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">j</button><button id="LIU_7" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">o</button><button id="LIU_8" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">g</button><button id="LIU_9" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">u</button><button id="LIU_10" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">a</button><button id="LIU_11" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">r</button><button id="LIU_12" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">m</button></div>
</form>
</div>
</div>
<div style="width: 460px; height: 100%; top: 0px; right: 0px; padding-left: 0px; position: fixed; background-color: white; z-index: 1000; display: none;">
<div style="border: 0px none; top: 1px; width: 100%; height: 42px; position: absolute;">
<form>
<div style="position: absolute; left: 2px; right: 0px;">
<input id="LIU_txt" style="border: 1px solid black; margin: 0pt; padding: 0pt; position: absolute; left: 0px; right: 240px; font-size: 14px ! important; height: 17px ! important; line-height: 50px; display: block;" />
<select id="LIU_sel" style="border: 1px solid black; margin: 0pt; padding: 0pt; position: absolute; width: 100px; right: 138px; font-size: 14px ! important; height: 17px;">
<option style="border: 0pt none; width: 30%; height: 19px;">Wikipedia</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Wictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Chambers (UK)</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google images</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google define</option>
<option style="border: 0pt none; width: 30%; height: 19px;">The Free Dictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Join example</option>
<option style="border: 0pt none; width: 30%; height: 19px;">WordNet</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Google</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Urban Dictionary</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Answers.com</option>
<option style="border: 0pt none; width: 30%; height: 19px;">rhymezone.com</option>
<option style="border: 0pt none; width: 30%; height: 19px;">Merriam-Webster</option>
</select>
<input id="LIU_search" style="border: 1px solid black; padding: 0pt; position: absolute; width: 68px; right: 68px; font-size: 14px ! important; height: 19px;" type="submit" value="Search" /><button id="LIU_prev" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 46px; height: 19px;">&lt;</button><button id="LIU_next" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 24px; height: 19px;">&gt;</button><button id="LIU_mode" style="border: 1px solid black; padding: 0pt; position: absolute; width: 20px; right: 2px; height: 19px;">0</button></div>
<div style="position: absolute; left: 2px; right: 0px; top: 22px;"><button id="LIU_0" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">w</button><button id="LIU_1" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">v</button><button id="LIU_2" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">c</button><button id="LIU_3" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">i</button><button id="LIU_4" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">d</button><button id="LIU_5" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">f</button><button id="LIU_6" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">j</button><button id="LIU_7" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">o</button><button id="LIU_8" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">g</button><button id="LIU_9" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">u</button><button id="LIU_10" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">a</button><button id="LIU_11" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">r</button><button id="LIU_12" style="border: 1px solid black; padding: 0pt; width: 20px; margin-right: 2px; height: 19px; background-color: white;">m</button></div>
</form>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.electricfairground.com/2009/08/08/image-map-rollover-effects-using-jquerys-maphilight-plugin/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>JQuery Image Dimensions</title>
		<link>http://www.electricfairground.com/2009/06/30/jquery-image-dimensions/</link>
		<comments>http://www.electricfairground.com/2009/06/30/jquery-image-dimensions/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 14:34:31 +0000</pubDate>
		<dc:creator>Lappa</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[dimensions]]></category>
		<category><![CDATA[height]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[width]]></category>

		<guid isPermaLink="false">http://www.electricfairground.com/?p=28</guid>
		<description><![CDATA[<a href="http://www.electricfairground.com/2009/06/30/jquery-image-dimensions/"><img align="left" hspace="5" width="150" src="image.png" class="alignleft wp-post-image tfe" alt="My Image" title="" /></a>Simple code to grab the dimensions of any image on your page. Here&#8217;s an example: Tell JQuery to find out how big this image is by using: var width = $("#my_image").width(); var height = $("#my_image").height();]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.electricfairground.com%2F2009%2F06%2F30%2Fjquery-image-dimensions%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.electricfairground.com%2F2009%2F06%2F30%2Fjquery-image-dimensions%2F&amp;source=robinspots&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Simple code to grab the dimensions of any image on your page. Here&#8217;s an example:</p>
<pre class='brush: html'>
<img id="my_image" src="image.png" alt="My Image" />
</pre>
<p>Tell JQuery to find out how big this image is by using:</p>
<pre class='brush: js'>
var width = $("#my_image").width();
var height = $("#my_image").height();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.electricfairground.com/2009/06/30/jquery-image-dimensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
