具体的には、リンク (テキストと場所を含む) をコピーしてから、たとえばリンクとして Word に貼り付けられるようにしたいと考えています。
2288 次
2 に答える
6
実際のコードは次のとおりです。
var richText = "<a href=\"" + gContextMenu.linkURL + "\">" + gContextMenu.linkText() + "</a>";
var xfer = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
xfer.addDataFlavor("text/html");
var htmlString = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
htmlString.data = richText;
xfer.setTransferData("text/html", htmlString, richText.length * 2);
var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
clipboard.setData(xfer, null, Components.interfaces.nsIClipboard.kGlobalClipboard);
Components.interfaces.nsISupportsString
データがプレーンテキストである別の を作成し、それを同じに追加することxfer
もお勧めしますtext/unicode
于 2008-10-20T17:26:09.333 に答える
1
于 2008-10-20T15:34:43.317 に答える