How would I get the current URL with a javascript code that could be used in a bookmarklet? This code isn't working:
javascript:copy(window.location.href);
It needs to copy it to the clipboard. I need to support Firefox, Chrome and IE
What about a dialog from which you can copy the current URL?
javascript:void(prompt("URL:", location.href))
The void
part prevents the browser from navigating away when pressing OK or Cancel.
Putting the URL into the clipboard takes more work, and differs on distinct browsers. If you really want to put the data in the clipboard, mention the browsers you need to support.