What is the best way to copy text to the clipboard (multi-browser)?
I have tried:
function copyToClipboard(text) { if (window.clipboardData) { // Internet Explorer window.clipboardData.setData("Text", text); } else { unsafeWindow.netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); const clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper); clipboardHelper.copyString(text); } }
But in Internet Explorer it gives a syntax error. In Firefox, it says unsafeWindow is not defined.
A nice trick without using Flash: How does Trello access the user’s clipboard?
Related Posts:
- How do I copy to the clipboard in JavaScript?
- are there dictionaries in javascript like python?
- In reactJS, how to copy text to clipboard?
- Python script to copy text to clipboard
- Call Python function from JavaScript code
- Parse the JavaScript returned from BeautifulSoup
- Import Error: No module named numpy
- bash: pip: command not found
- Function for Factorial in Python
- Python ValueError: too many values to unpack
- How do I select rows from a DataFrame based on column values?
- How to parse XML and count instances of a particular node attribute?
- Importing files from different folder
- How to prevent errno 32 broken pipe?
- AttributeError: ‘module’ object has no attribute ‘urlopen’
- How to read a local text file?
- Open a URL in a new tab (and not a new window)
- Pandas group-by and sum
- Python pandas groupby aggregate on multiple columns, then pivot
- Factorial in numpy and scipy
- How to remove specific substrings from a set of strings in Python?
- How do I install the yaml package for Python?
- Python: Array v. List
- What is key=lambda
- __init__() takes 1 positional argument but 2 were given
- Node.js – SyntaxError: Unexpected token import
- jQuery animate backgroundColor
- unittest Vs pytest
- How to change css property using javascript
- JavaScript get element by name
- How do I disable right click on my web page?
- Left() function in Javascript or jQuery
- Add single element to array in numpy
- JavaScript Loading Screen while page loads
- ‘Can’t set attribute’ with new-style properties in Python
- Why is “forEach not a function” for this object?
- How to check if a string is a substring of items in a list of strings?
- How to index into a dictionary?
- How do I check if there are duplicates in a flat list?
- How to Open New window on every Click
- Jquery Ajax Call, doesn’t call Success or Error
- Difference between scikit-learn and sklearn
- How can I create a text input box with Pygame?
- How to set onClick with JavaScript?
- Substitution Cipher Python
- How does += (plus equal) work?
- Javascript Comparison Operators != vs !==
- How to create a density plot in matplotlib?
- JavaScript check if variable exists (is defined/initialized)
- Why am I getting this unexpected keyword argument TypeError?
- Embedding instagram webpage inside an iframe
- Do something if screen width is less than 960 px
- Create numpy matrix filled with NaNs
- python pandas remove duplicate columns
- ubuntu /usr/bin/env: python: No such file or directory
- Javascript – Replace html using innerHTML
- Syntax error: Illegal return statement in JavaScript
- Error: TypeError: $(…).dialog is not a function
- How to completely uninstall python 2.7.13 on Ubuntu 16.04
- Calculate weighted average using a pandas/dataframe
- Telling Python to save a .txt file to a certain directory on Windows and Mac
- Correct modification of state arrays in React.js
- Angular 2 Sort table columns
- Simplify Chained Comparison
- How to get POSTed JSON in Flask?
- JavaScript string encryption and decryption?
- How to fix SSL issue SSL_CTX_use_certificate : ca md too weak on Python Zeep
- Validating Custom Meta Box Values & Required Fields
- Check javascript file Proper way in functions.php
- preserve url parameters from affliliate sites
- How to speed up admin-ajax.php in wordpress
- What javascript libs & frameworks are integrated in WordPress vanilla?
- Conditional fields in contact form 7 not working
- Enqueueing a script and a style sheet not working
- Uppload image from another source wp.media
- Use onfocus event in Contact Form 7
- Get Block Attributes in JSON REST API
- Static page to one page- menu inactive items highlighted
- Performance optimization of tree like structure
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- How to properly Remove certain CSS / JS files from template
- how do i in ignore/disable/delete a javascript call from parent in child theme?
- “Conflict” with jQuery (or its plugins)?
- url – ajax loaded but no JS
- enqueue script won’t work (enqueue style does work)
- Ajaxurl suddenly not defined
- Social share buttons text shows up on post excerpts
- How would I create the same popup in css and javascript as the one in contact button on the site https://www.sublimotionibiza.com/es/main.html [closed]
- Plugin Admin panel checkbox unchecked after submit
- How to get file object from file_attachment?
- Creating a brand attribute as a variable
- How do I load urls from an external .js file to my admin head?
- Nothing in dashboard that uses javascript works
- Creating a User-Adjustable chart in WordPress
- How to execute WP shortcode in a javascript string “”
- Trouble with adding preloader to my home page index.html and index.js
- Creating custom URL for async content
- How do I convince this button to do something when it is clicked?
- Replacing & in JS code on pages
- javscript that updates div in a single wordpress page