Last active
March 24, 2016 11:12
-
-
Save PixelRobot/add98a9a2fcec69f050e to your computer and use it in GitHub Desktop.
A bookmarklet for linking to fragments inside a text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:( | |
function(win, doc){ | |
var text = ""; | |
if (win.getSelection) { | |
text = win.getSelection().toString(); | |
} else if (doc.selection && doc.selection.type != "Control") { | |
text = doc.selection.createRange().text; | |
} | |
url = window.location.toString(); | |
window.location = url.split("#")[0] + "##" + text; | |
} | |
)(window, document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Select a fragment of text in a document, click on the bookmarklet, and you'll get a link to that fragment in the address bar in your browser.