{"id":579,"date":"2018-12-08T07:51:14","date_gmt":"2018-12-08T12:51:14","guid":{"rendered":"https:\/\/www.markwheeler.com\/wordpress\/?p=579"},"modified":"2018-12-08T07:51:14","modified_gmt":"2018-12-08T12:51:14","slug":"sharepoint-2016-copy-shortcut-context-menu","status":"publish","type":"post","link":"https:\/\/markwheeler.com\/?p=579","title":{"rendered":"SharePoint 2016 Copy Shortcut Context Menu"},"content":{"rendered":"<p>After an upgrade from SP2013 to SP2016, the ability to right-click on a document and copying a shortcut was removed. This is because the IE right-click menu has been replaced by a context sensitive menu that does not include an option for copying a shortcut to the document. The following code will put that back&#8230;<\/p>\n<pre>\/\/ Add \"Copy Shortcut\" option to document context menu\n$(document).ready( function () {\n\/\/ Use setInterval to run this every 100ms\nsetInterval(\nfunction () {\n\/\/ Check if a \"Copy shortcut\" button is already displayed\nvar n = $('#copyShortcutMenuItem').length;\nvar m = $('.ms-core-menu-list').length;\nif (n == 0 &amp;&amp; m &gt; 0) {\nvar firstMenuItem = $('li.ms-core-menu-item:first-of-type');\nvar hlink = firstMenuItem.parent().parent().parent().find('div:first-of-type').attr('Url');\nif (hlink.startsWith('\/')) {\nhlink = \"https:\/\/\" + window.location.host + hlink; \n}\n\/\/ Build the HTML of the new list item\nvar newHtml = '\n\n \t<li id=\"copyShortcutMenuItem\" class=\"ms-core-menu-item\" type=\"option\" text=\"Copy Shortcut\"><a title=\"Copy a link to this document to the clipboard\" class=\"ms-core-menu-link\" href=\"\/\" onclick=\"CopyShortcutClick(\\'' + hlink + '\\');\">Copy Shortcut<\/a><\/li>\n\n';\n\/\/ Insert the list item\n$(newHtml).insertBefore(firstMenuItem);\n}\n}, 100\n);\n});\n\/\/ Set the clipboard and hide the menu\nfunction CopyShortcutClick(t) {\nwindow.clipboardData.setData('Text', t);\n$('.ms-core-menu-list').parent().hide();\n}\n<\/pre>\n<p>Save this as CopyShortCut.js and put it in your root Site Assets library. Also download the latest <a href=\"https:\/\/jquery.com\/download\/\">JQUERY<\/a>. Add the following to the &lt;Head&gt; of your master page.<\/p>\n<pre><script type=\"text\/javascript\" src=\"\/SiteAssets\/jquery-3.1.1.min.js\"><\/script>\n<script type=\"text\/javascript\" src=\"\/SiteAssets\/CopyShortCut.js\"><\/script><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>After an upgrade from SP2013 to SP2016, the ability to right-click on a document and copying a shortcut was removed. This is because the IE right-click menu has been replaced by a context sensitive menu that does not include an option for copying a shortcut to the document. The following [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":581,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2,10,11],"tags":[],"class_list":["post-579","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computer","category-sharepoint","category-software"],"jetpack_featured_media_url":"https:\/\/markwheeler.com\/wp-content\/uploads\/2018\/12\/copyshortcut31.png","_links":{"self":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=579"}],"version-history":[{"count":0,"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/579\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/media\/581"}],"wp:attachment":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}