Mr Portman

School website critiques, articles on education and some random cod

Check url using Javascript

Tags: ,

Date: 18th July, 2010

Ages ago I commented somewhere and left a link to my site within the comment which included the ID of a div called learning_resources (http://mrportman.co.uk/#learning_resources). Since then the div no longer exists, but I wanted to offer those visitors the download still.

You can’t do anything with PHP because anything with a # isn’t passed to the server, so I had to resort to some Javascript and search the url:

$(document).ready(function() {

$url = $(location).attr(‘href’);
$string = “learning”
if ($url.search($string) == 24) {
<!– Do your thang here –>
}
});

August 2010

July 2010

June 2010

May 2010

April 2010

February 2010

January 2010

December 2009

November 2009

October 2009

September 2009