Friday, February 13, 2009

Opening links in a new window

Like it or not, people often expect certain documents (i.e. PDFs) to open in a tab or window. Often enough, the ugly solution of target="top" or similar is used otherwise JavaScript is employed to redirect links. Both methods are a wonderful source of confusion and annoyance.


With this in mind, I cobbled together my own solution employing the wonders of jQuery to handle the selectors:


$(function(){
$("a[href$='.pdf']").click(function(e){
//don't interfere with modifier keys
if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {
return true;
}
window.open($(this).attr("href"));
return false;
}).attr("title", function(){
return this.title + " (Opens in a new window)"
});
});

Two key things happen here: modifier keys are left alone so power users are happy and the anchor”s title is altered to give users a hint of what’s going on.

Sunday, January 4, 2009

Portugal and beyond

We are now in warm Portugal (compared to the rest of the trip, it is really warm!)

But first, a little recap as we were last in Berlin.

For those who aren´t aware, we spent a white Christmas in Levi, Finland. It´s the home of crazy reindeer, lots of snow and Santa!!! We had the most fantastic time in which we got pulled around by reindeer in sleds, rode snowmobiles at fantastic speeds (sort of), met some huskies who enjoyed eating people´s hands, elf-skippd in the snow-covered forest at night and caught some fish on a lake that had 30cm of frozen ice. It was incredible - photos will come later.

Berlin was also a fantastic experience. It involved eating and sampling lots of the local delicasies which were generally Berliners or gummy bears. Saw lots of the local historical areas - museums of ancient Egypt and Babylonian times (the Pokemon museum!) and staying in Checkpoint Charlie, saw that important area. New Year´s was an amazing experience in which we were packed into the Tiergarten with stages, food, fireworks and 1 million people. The fireworks were the most interesting as people are allowed to set them off everywhere, including in the street right next to you.
We ended our time in Berlin with some snowfall and maybe a couple of snowballs being thrown..

We are now in Portugal, staying about an hour out of Lisbon with Sarah´s aunt and cousins. Today we went to Obidos - a castle (a real castle) which still had its wall and village inside the wall intact and functioning. An amazing sight for people who come from a country that definately doesn´t have any castles. We will be staying in Lisbon on Tuesday and Wednesday and then we start our journey home.