Return to Snippet

Revision: 16721
at August 13, 2009 08:38 by Meander365


Initial Code
//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;}}

Initial URL

                                

Initial Description
Create two new bookmarks - one for dev, one for live and add the following corresponding code to each.

Initial Title
Bookmarklet : Switch Between Servers But Keep The Same Path

Initial Tags
javascript, server

Initial Language
JavaScript