Skip to content

Instantly share code, notes, and snippets.

@kevadsett
Last active December 22, 2015 03:38
Show Gist options
  • Select an option

  • Save kevadsett/6411458 to your computer and use it in GitHub Desktop.

Select an option

Save kevadsett/6411458 to your computer and use it in GitHub Desktop.
Change local mode (file://c:/whatever) to localhost mode (http://localhost/whatever) – requires symbolic link in server's htdocs folder.
var url = document.URL,
currentLocation = url.split("//"),
newURL = "",
path = "";
if(currentLocation[0] == "file:"){
path = url.substring(11, url.length);
newURL = "http://localhost/" + path;
}
document.location = newURL;
@kevadsett
Copy link
Author

This is useful as a bookmarklet, just add javascript: before the minified code, and add the whole thing as the URL to a new bookmark in your browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment