Subdomain Bookmarklet Builder
Builds a bookmarlet link for switching to different subdomains (dev,www, etc).
by dannygarcia
HTML
<input id="in" /><br>
<a id="bm" href="javascript:void((function(){var%20e='www';var%20s=location.host.split('.');s[0]=e;s=s.join('.');s=location.href.replace(location.host,s);location=s})())">www</a>
JavaScript
$(function() {
$('#in').bind('change keydown keyup', function() {
var val = $(this).val(),
newh = "javascript:void((function(){var%20e='"+val+"';var%20s=location.host.split('.');s[0]=e;s=s.join('.');s=location.href.replace(location.host,s);location=s})())";
$('#bm').text(val).attr('href',newh);
});
});