Microsoft Edge Copy Title and URL of a Web Page [Bookmarklet]

There are several third-party extensions out there to copy webpage title and address, for browsers like Chrome, Firefox and others. Here is a neat trick to add your own Copy Title & URL bookmarklet for Microsoft Edge.

Copy Title and URL Bookmarklet for Microsoft Edge

In Microsoft Edge (Chromium), create a bookmark to a sample site.

Then replace (edit) the URL of the bookmark with the following target:

javascript:(function() { function copyToClipboard(text) { if (window.clipboardData && window.clipboardData.setData) { /*IE specific code path to prevent textarea being shown while dialog is visible.*/ return clipboardData.setData("Text", text); } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) { var textarea = document.createElement("textarea"); textarea.textContent = text; textarea.style.position = "fixed"; /* Prevent scrolling to bottom of page in MS Edge.*/ document.body.appendChild(textarea); textarea.select(); try { return document.execCommand("copy"); /* Security exception may be thrown by some browsers.*/ } catch (ex) { console.warn("Copy to clipboard failed.", ex); return false; } finally { document.body.removeChild(textarea); } } } var markdown = document.title + ':' + '\r\n' + window.location.href; copyToClipboard(markdown); })();

microsoft edge chromium - copy title and url

Visit a website and click on the bookmarklet. It will copy the title and the URL of the current webpage, in the following format:

Microsoft Edge Copy Title and URL of a Web Page [Bookmarklet] » Winhelponline:
https://www.winhelponline.com/blog/edge-copy-title-url-web-page-bookmarklet/

Credits to bradleybossard/titleUrlMarkdownClip.js — Bookmarklet to copy current page title and url

The above javascript code also works on Google Chrome, Firefox, and other browsers.

Instructions for the old Microsoft Edge

Open Microsoft Edge, visit a website, and add it to the Favorites bar. Name the favorite as Copy Title & URL, or anything as you’d like.

edge copy title and url bookmarklet

Now, we’ll change that favorite’s target to a javascript code, which copies the page title and URL of the current tab. As of Windows 10 Fall Creators Update you can edit the URL of an existing bookmark in Edge. To do that, right-click on the bookmark and click Edit URL. Type in the following javascript code and press ENTER:

javascript:window.prompt("Copy Title & URL",document.title + " : " + location.href);void(0);

The above javascript code gets the title and website address of the current webpage and shows it in a text box which you need to copy (CTRL + C)



Start Microsoft Edge, visit a website, and then click the Copy Title & URL bookmarklet you created.

edge copy title and url bookmarklet

You’ll be shown the following prompt with a text control box, showing the title, which is followed by the URL of the webpage. The text range is automatically selected for you.

edge copy title and url bookmarklet

Due to security restrictions in the old Microsoft Edge web browser, javascript can’t copy stuff to the clipboard directly without the user’s consent, and hence the additional prompt above. Likewise, a new line or carriage return doesn’t seem to work in Edge. So the title and URL will be outputted in a single line as below:

Lifehacker - Tips and downloads for getting things done : http://lifehacker.com/

All you need to do is press Ctrl + C to copy the text to the clipboard and dismiss the dialog by clicking OK or pressing the ESC key.


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded Winhelponline.com in 2005.

3 thoughts on “Microsoft Edge Copy Title and URL of a Web Page [Bookmarklet]”

  1. Hi,

    I think this is a very cool concept, but it doesn’t do exactly the same as MS Edge, however. When I use this on this page, this it the result:

    Microsoft Edge Copy Title and URL of a Web Page [Bookmarklet] » Winhelponline:
    https://www.winhelponline.com/blog/edge-copy-title-url-web-page-bookmarklet/

    In MS Edge, it would have returned the page title as a hyperlink, which I think is more elegant. De you know if this is possible at all with javascript? I am very much a dabbler in it. I tried to change the last bit of the code to this:

    var markdown = document.title; copyToClipboard(markdown.link(window.location.href)); })();

    But then the result is this:

    Microsoft Edge Copy Title and URL of a Web Page [Bookmarklet] » Winhelponline

    Which… would be a hyperlink in HTML, but is not exactly what I’m trying to do here.

    Anybody has any idea how to do this / if it’s possible?

    Reply

Leave a Reply