<?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>iBlog random &#187; links</title>
	<atom:link href="http://blog.zurka.us/tag/links/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.zurka.us</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 28 May 2013 20:28:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6</generator>
		<item>
		<title>Change the location of your external links with MooTools</title>
		<link>http://blog.zurka.us/change-location-your-external-links-mootools/</link>
		<comments>http://blog.zurka.us/change-location-your-external-links-mootools/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 18:02:52 +0000</pubDate>
		<dc:creator>nasal</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.zurka.us/?p=1050</guid>
		<description><![CDATA[So a thing I was trying to do for quite some time now but using php and rexep, which I hate and don&#8217;t understand at all, was trying to change the location (href) of all the external links on my page to something else so I could easily track the clicks. Or maybe display some [&#8230;]]]></description>
				<content:encoded><![CDATA[<div style="padding-top:15px;padding-right:0px;padding-bottom:0px;padding-left:0px;;" class="linksalpha_widget">
											<iframe
												style="height:25px !important; border:0px solid gray !important; overflow:hidden !important; width:550px !important;" frameborder="0" scrolling="no" allowTransparency="true"
												src="http://www.linksalpha.com/social?blog=iBlog+random&link=http%3A%2F%2Fblog.zurka.us%2Fchange-location-your-external-links-mootools%2F&title=Change+the+location+of+your+external+links+with+MooTools&desc=So+a+thing+I+was+trying+to+do+for+quite+some+time+now+but+using+php+and+rexep%2C+which+I+hate+and+don%27t+understand+at+all%2C+was+trying+to+change+the+location+%28href%29+of+all+the+external+links+on+my+page+to+something+else+so+I+could+easily+track+the+clicks.+Or+maybe+display+some+kind+of+toolbar+on+top+of&fc=333333&fs=arial&fblname=like&fblref=facebook&fbllang=en_US&fblshow=1&fbsbutton=1&fbsctr=1&fbslang=en&fbsendbutton=1&twbutton=1&twlang=en&twmention=&twrelated1=&twrelated2=&twctr=1&lnkdshow=noshow&lnkdctr=1&buzzbutton=1&buzzlang=en&buzzctr=1&diggbutton=1&diggctr=1&stblbutton=1&stblctr=1&g1button=1&g1ctr=1&g1lang=en-US">
											</iframe>
										</div><p>So a thing I was trying to do for quite some time now but using php and rexep, which I hate and don&#8217;t understand at all, was trying to <strong>change the location</strong> (href) <strong>of all the external links</strong> on my page to something else so I could easily <strong>track</strong> the clicks. Or maybe display some kind of toolbar on top of the page, something like I guess digg does.</p>
<p>Today I remembered that <a href="http://mootools.net/">MooTools</a> is my friend and I could use it to accomplish this.. and after 2 minutes and 5 lines of code I did it!</p>
<p>I&#8217;m guessing you already have <a href="http://mootools.net/">MooTools</a> up and running. Let&#8217;s take a look at the code.</p>
<pre class="brush: php">
$$(&#039;a&#039;).each(function(link) {
    if(link.hostname != window.location.host) {
        var loc = link.get(&#039;href&#039;);
        link.set(&#039;href&#039;, &#039;./out.php?&#039; + loc);
    }
});
</pre>
<p>So we create an <strong>array of all the links</strong> on our site and check if their <strong>hostname</strong> is the same as the hostname of our site. If it is different we <strong>read the value</strong> of href (the link) and change it to <strong>our php</strong> script that is going to track the click (or whatever) and add the previous link, so it knows where it should be redirected.</p>
<p>This is it! Easy peasy!</p>
<p>Oh and have a happy December!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zurka.us/change-location-your-external-links-mootools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
