Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using the netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect') for firefox.

i am facing the problem for browser compatability for editor. we are using HTML EDITOR.

In IE all version cut, copy and paste is working for this editor.

when comes to mozilla, these are working only upto some versions only. it is not working in firefox 15 onwords....

when i right click, the cut, copy and paste are disabled. eventhough shotcut keys are also not working.

can any one know this? please clarify above issues ASAP.

we are using for this copy the selected text. here is a sample code for this:

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( /
/g, '<br/>' ) ;
window.activeEditor._inserthtml( code ) ;
};

Thank you...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
262 views
Welcome To Ask or Share your Answers For Others

1 Answer

From Mozilla's support pages;

Starting in Firefox 17 privileged code can not run in a web page anymore. In Firefox 15 you have to manually change a setting to enable it. You can bring that kind of functionality to an extension. Starting points: https://developer.mozilla.org/en-US/docs/Code_snippets/Interaction_between_privileged_and_non-privileged_pages

For beginners: https://developer.mozilla.org/en-US/docs/XUL_School/Getting_Started_with_Firefox_Extensions

More information: https://developer.mozilla.org/en-US/docs/Bypassing_Security_Restrictions_and_Signing_Code

Here you can find a (somewhat heated) discussion on the subject that has been going on for a couple of years :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...