阅读:1050回复:0
【求助】请教 扩展JS 代码问题,谢谢各位大大!var CopyLinkNameAndURLOverlay = { Init : function () { document.getElementById("contentAreaContextMenu").addEventListener("popupshowing", CopyLinkNameAndURLOverlay.linkPopup, true); }, linkPopup : function () { document.getElementById("clnu-link-context").hidden = (!gContextMenu.onLink); document.getElementById("clnu-link-title").hidden = (!gContextMenu.onLink); document.getElementById("clnu-tabbar-context").hidden = (gContextMenu.onLink || gContextMenu.isTextSelected || gContextMenu.onImage || gContextMenu.onTextInput); document.getElementById("clnu-tabbar-contexturl").hidden = (gContextMenu.onLink || gContextMenu.isTextSelected || gContextMenu.onImage || gContextMenu.onTextInput); }, CopyOnLink : function () //链接地址和标题 { var Turl = "getLinkURL" in gContextMenu ? gContextMenu.getLinkURL() : gContextMenu.linkURL(); var Ttitle = CopyLinkNameAndURLOverlay.Copytitle(); Components.classes['@mozilla.org/widget/clipboardhelper;1'].getService(Components.interfaces.nsIClipboardHelper).copyString(Ttitle + ' ' + Turl); }, Copytitle : function () //复制当前标题 { var title = window.content.document.title; var pageurl = window.content.location.href; var r = ''; if (pageurl.indexOf("127.0.0.1") > 0) { r = title.split(/,.{1,20},/, 1); } else if (pageurl.indexOf("book.zongheng.com") > 0) { r = title.split('最新章节,', 1); // } else { r = title; } Components.classes['@mozilla.org/widget/clipboardhelper;1'].getService(Components.interfaces.nsIClipboardHelper).copyString(r); return r; } } window.addEventListener("load", CopyLinkNameAndURLOverlay.Init, true); 问题: CopyOnLink : function () //链接地址和标题 (Ttitle + ' ' + Turl); turl 没有取到。 经常是只复制了标题,链接地址没有了,没有值。请问大大们,哪里出错了。找了没有找到。 |
|
|