/ Published in: JavaScript
Create two new bookmarks - one for dev, one for live and add the following corresponding code to each.
Expand |
Embed | Plain Text
//dev javascript:f=parent.document.URL;l=false;q=false;if(f.indexOf('#')>0){l=f.substring(f.indexOf('#'),f.length);}if(f.indexOf('?')>0){q=f.substring(f.indexOf('?'),f.length);}if(l&&q||q&&!l){location.href='http://my-dev-server-path'+location.pathname+q;}else{if(l&&!q){location.href='http://my-dev-server-path'+location.pathname+l;}else{location.href='http://my-dev-server-path'+location.pathname;}} //live javascript:f=parent.document.URL;l=false;q=false;if(f.indexOf('#')>0){l=f.substring(f.indexOf('#'),f.length);}if(f.indexOf('?')>0){q=f.substring(f.indexOf('?'),f.length);}if(l&&q||q&&!l){location.href='http://my-live-server-path'+location.pathname+q;}else{if(l&&!q){location.href='http://my-live-server-path'+location.pathname+l;}else{location.href='http://my-live-server-path'+location.pathname;}}
Comments
Subscribe to comments
You need to login to post a comment.

Here's a way to do the same thing but with one bookmarklet. Let me know if you see any limitations to this approach.
javascript:(function(){var d='localhost';var p='mydomain.com';var s=document.domain.indexOf(d)!=-1?p:document.domain.indexOf(p)!=-1?d:0;if(s)location.href=document.location.toString().replace(document.domain,s);})()
http://snipplr.com/view/24448/server-switcher-bookmarklet/ also posted here: http://hacklite.com/2009/12/server-switching-bookmarklet/