JK Web Studio is a small web design studio, specializing in efficient and user friendly solutions.

Contact us at info@jkwebstudio.com

Archive for November, 2009

Bookmarklet for easy switching between development and production web environments

Monday, November 30th, 2009

When I develop websites, I like to set up a development site on my local web server. I usually name it the same as the production site, but with a ‘local’ prefix. So if the production site is acme.com, my development site will be localacme.com.

I wrote a little bookmarklet for easy switching between the two sites. It checks to see if the new url starts with ‘http://local’. If it does, ‘local’ will be deleted from the url, if not, local will be inserted.

Here is the code for the bookmarklet:

javascript:(function(){u=location.href.replace(%22http://www.%22,%22http://%22);a=%22http://local%22;b=%22http://%22;l=(u.indexOf(a)==0)?u.replace(a,b):u=u.replace(b,a);location.href=l;})()