Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. javascript:(function() {
  2.  
  3. function copyToClipboard(text) {
  4. if (window.clipboardData && window.clipboardData.setData) {
  5. /*IE specific code path to prevent textarea being shown while dialog is visible.*/
  6. return clipboardData.setData("Text", text);
  7.  
  8. } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
  9. var textarea = document.createElement("textarea");
  10. textarea.textContent = text;
  11. textarea.style.position = "fixed"; /* Prevent scrolling to bottom of page in MS Edge.*/
  12. document.body.appendChild(textarea);
  13. textarea.select();
  14. try {
  15. return document.execCommand("copy"); /* Security exception may be thrown by some browsers.*/
  16. } catch (ex) {
  17. console.warn("Copy to clipboard failed.", ex);
  18. return false;
  19. } finally {
  20. document.body.removeChild(textarea);
  21. }
  22. }
  23. }
  24.  
  25. var markdown = document.title + ' - ' + window.location.href;
  26. copyToClipboard(markdown);
  27. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement