Is anyone else experiencing issues with cut, copy, and paste functionality not working on Firefox 15 and later versions

I am encountering an issue with browser compatibility for the HTML editor while using netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect') in Firefox.

In Internet Explorer, all versions have functioning cut, copy, and paste capabilities in the editor.

However, in Mozilla Firefox, these features are only supported up to certain versions and do not work from Firefox 15 onwards. When attempting to right-click, the cut, copy, and paste options are disabled, and even shortcut keys fail to work.

If anyone has knowledge regarding this issue, please provide clarification as soon as possible.

We use the following code snippet to copy selected text:

PasteText.prototype.execute = function()
{

netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
if (!clip) {
    return;
}
var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
if (!trans) {
    return;
}
trans.addDataFlavor('text/unicode');
clip.getData(trans,clip.kGlobalClipboard);
var str = new Object();
var len = new Object();
try {
    trans.getTransferData('text/unicode',str,len);
}
catch(error) { return; }
if (str) {
    if (Components.interfaces.nsISupportsWString) {
        str=str.value.QueryInterface(Components.interfaces.nsISupportsWString);
    } else if (Components.interfaces.nsISupportsString) {
        str=str.value.QueryInterface(Components.interfaces.nsISupportsString);
    } else {
        str = null;
    }
}

if (str) {
    var code = str.data.substring(0,len.value / 2);
}
code = code.replace( /\n/g, '<br/>' ) ;
window.activeEditor._inserthtml( code ) ;
};

Thank you...

Answer №1

According to information found on Mozilla's support pages:

Starting with Firefox 17, privileged code is no longer able to run within a web page. In Firefox 15, manual adjustments were required to enable this functionality. This kind of capability can now be brought to an extension. Resources for getting started: https://developer.mozilla.org/en-US/docs/Code_snippets/Interaction_between_privileged_and_non-privileged_pages

For those new to the process: https://developer.mozilla.org/en-US/docs/XUL_School/Getting_Started_with_Firefox_Extensions

Additional insights can be found here: https://developer.mozilla.org/en-US/docs/Bypassing_Security_Restrictions_and_Signing_Code

To engage in a lively discussion that has been ongoing for some time, check out this link: Here :)

Answer №2

For a solution, I suggest using ZeroClipboard. This method involves selecting an element by its ID and overlaying it with a transparent flash video of equal size. By utilizing Flash, you can gain access to the clipboard for cutting/copying tasks. Keep in mind that this option may not be ideal for Apple devices.

To ensure compatibility, make sure your users have at least Flash version 9 installed. You can use swfobject to verify the required version before proceeding.

if (swfobject.hasFlashPlayerVersion('9')) {
    $.getScript('/js/ZeroClipboard.min.js', function(){
         ZeroClipboard.setMoviePath('/swf/ZeroClipboard10.swf');
         var clip = new ZeroClipboard.Client;
         clip.setCSSEffects(true);
         clip.setHandCursor(true);
         clip.glue('copy-elem-id', 'copy-elem-id-container');
         clip.addEventListener('onMouseDown', function(e){
             var copyText = $('#textbox-id').text();
             clip.setText(copyText);
         });
    });
}

Answer №3

To grant specific privileges, we must make modifications in about:config without using quotation marks.

user_pref("capability.policy.policynames", "allowclipboard"); user_pref("capability.policy.allowclipboard.sites", ""); user_pref("capability.policy.allowclipboard.Clipboard.cutcopy", "allAccess"); user_pref("capability.policy.allowclipboard.Clipboard.paste", "allAccess");

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using jQuery to slide elements across the page

I've been attempting to incorporate a sliding effect into my website, but I'm running into an issue where the sliding only occurs on the first click and I can't figure out why. Here is the code snippet I've been using: Html : $("#go ...

Ways to analyze and contrast two ajax replies post parsing

Is there a different way to write code for making ajax calls for two pages within a single function? Also, I am looking for a method to compare the responses from both requests, specifically comparing objects y2 and y3. function compareResponses() { ...

Finding the right way to cancel a Firestore stream within a Vue component using the onInvalidate callback

Currently, I am utilizing Vue 3 to develop a Firebase composable that is responsible for subscribing to an onSnapshot() stream. I have been attempting to unsubscribe from this stream by invoking the returned unsubscribe() function within both watchEffect ...

How can you determine whether the CSS of a <div> is defined in a class or an id using JavaScript/jQuery?

Hey there, I'm currently working on dynamically changing the CSS of a website. Let's say we have a div like this: <div id="fooid" class="fooclass" ></div> The div has a class "fooclass" and an ID "fooid", and we're getting its ...

In order to enhance user experience, I would like the tabs of the dropdown in the below example to be activated by

function openCity(evt, cityName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } ...

How can I implement long polling effectively with jQuery and AJAX?

Currently, I am working on a project that requires live notifications. I considered using socket.io, but due to time constraints, I decided to explore AJAX and jQuery as alternatives. I have outlined my code structure below and I am curious if this appro ...

Navigating Redirect Uri in Ionic for third-party API integration

After creating a webapp, I decided to venture into developing a mobile app using Ionic. The idea of making a progressive web app crossed my mind, but unfortunately Apple doesn't support it yet. (By the way, I'm still quite new to all of this) F ...

Adding elements dynamically to a list using Vue.js based on user input

One of the features in my Vue.js project involves adding facilities and appliances to a house using a form section. I have an input field for entering a facility and a button to add it to a list, but I'm unsure about how to implement this functionalit ...

How to effectively utilize string concatenation in AngularJS for the src attribute of an HTML img

I am currently utilizing the YouTube API v3 to extract videos from a playlist. Each video JSON object includes a unique videoId. My aim is to use this videoId to construct the src attribute in the img element using Angular. Here's my current setup: ...

How to retrieve the id of a different view using Backbone

On one of my views, there is a search box with a "Search" button that has an id of "search". In another view, I want to perform a search when the "Search" button is clicked. However, in order for this to work, I need to access the id. How can I accomplish ...

Choose the specific selector following the current selector

Consider this example of code: <script> $(document).ready(function () { $('span').each(function () { $(this).html('<div></div>') ; if ( $(this).attr('id') == 'W0' ...

Compressing tool combining Google App Engine with Angular JS

Seeking advice on setting up a minifier, like Google Closure, to integrate with Google App Engine. I am using AngularJS for the client side and have multiple JS files that I want to serve as one minified file during production. How can I achieve this witho ...

Ensure to preselect the radio button based on the Day's value

I have set up my Radio buttons with corresponding content to be displayed when clicked. I want to automatically pre-select the tab button based on the current day. For example, if today is Sunday, the page should load showing the contents for Sunday. If i ...

Updating the HTML class with JavaScript

My HTML class has two classes $(document).ready(function() { $(".container").hover(function() { $('.green').addClass('display-on'); }); $(".container").mouseleave(function() { $('.black&apos ...

Executing scripts within various node project directories using npm

Creating Concurrent NPM Scripts In my main project, I have several node projects nested as subdirectories. Each of these projects has its own node_modules directories and package.json files. My goal is to define an npm script in the main project's pa ...

selenium-webdriver waits for mouse movement before proceeding

Currently, I am creating test automation using Selenium, Protractor, and Jasmine for an Angular web application. The tests are being run within VirtualBox (Host OS: Windows 8, Guest OS: Ubuntu 15.04). At this point, the test is quite basic, with the onPrep ...

Using Regular Expressions in Javascript

I have gone through numerous posts with this title, but so far, none of them have addressed my specific query... My requirement is to utilize regex in the following format: "/^ user provided input $/i". The user can include the special regex character * e ...

Unexpected behavior observed in while loop with dual conditions

To break the while loop, I need two conditions to be met - res must not be undefined, which only happens when the status code is 200, and obj.owner needs to match a specific value I have set. Since it takes a few seconds for the owner on that page to updat ...

Understanding how to incorporate a URL parameter using HTML and Javascript

I have a web application section where users can search for locations on a map successfully. However, I'd like the text of the location to be displayed in the URL so that users can easily copy and share it for consistent searches. What is the most ef ...

Guide on making a reusable pagination child component in VueJS

As a developer, I am currently utilizing Element-UI to speed up the development process of my applications. One feature I want to implement is pagination as a reusable child component within any parent component in order to decrease the overall app size. ...