Open All External Links in New Tabs

Posted: August 4th, 2010 | Filed under: General

Here is a quick bit of jQuery to make all external links have the target=_blank attribute.

<script type="text/javascript">
$(function(){
$("a[href^='http:']").not("[href*=EXAMPLE.com']").attr({ target: "_blank" });
});
</script>

You could also use this same technique to add a small friendly image next to these links  notifying the user they are about to leave the site.

<script type="text/javascript">
$(function(){
$("a[href^='http:']").not("[href*=EXAMPLE.com']").attr({ target: "_blank" }).append(" <img src=\"outLink.jpg\">");
});
</script>

301 Redirect using URLRewrite

Posted: May 11th, 2010 | Filed under: General

Just in case.. A 301 redirect tells the browser/search engine that the page has permanently been moved to this new address.

First install URLRewrite on a windows server with IIS7 from  http://www.iis.net/download/URLRewrite

After its installed a new button titled URL Rewrite will be added. Select it.

IIS7 URL Redirect

Under Actions click Add Rule(s)

Select Rule with URL Rewrite map

IIS7 Rule With Rewrite MapChange the Rule Action to Redirect and give it any name you wish it makes no difference what it is.

Then under actions click Add Mapping Entry

IIS7 MappingIn the Original Value field give the path to the old page without the http://www.example.com in the above example it redirects /oldpage.html to /newpage.html

Keep adding new Mapping Entries for every page you need to redirect.


jquery to solve the 100% height problem

Posted: January 12th, 2010 | Filed under: General

Real short post today just a quick snippet of jQuery that solves the 100% height problem.

Yes there are complete CSS solutions to this but it seems that at times they can be problematic, and at other times laziness can kick in.

$(document).ready(function () {
    $("#divID").height($(document).height());
});

//And the slightly more fancy way. With a subtle slide down.

$(document).ready(function () {
    $("#divID").animate({ height: $(document).height() }, 500 );
});