URL Rewriting in JavaScript
At work I am constantly flipping between a production and a development web server. The live site would have a URL like, "www.mysite.com" and the development site one like, "dev.mysite.com". I was getting tired of removing the "www" from the address and replacing it with "dev" and back again for all the different URLs. This script is a result of that. By simply clicking a saved bookmark on my browser toolbar I can automatically switch back and forth between the production and development servers with ease.
Right-click on the following link, DevSwitch, and select either "Bookmark This Link..." in FireFox or "Add to Favorites..." in Internet Explorer.
The Bookmarklet code is outlined below.
javascript:(function(){
x=location.href;
y=(x.indexOf('www')!=-1)?x.replace('www','dev'):x.replace('dev','www');
location.href=y;
})()
