pingfan5888
小狐狸
小狐狸
  • UID50491
  • 注册日期2015-07-15
  • 最后登录2015-11-18
  • 发帖数20
  • 经验30枚
  • 威望0点
  • 贡献值24点
  • 好评度1点
  • 社区居民
阅读:1052回复:0

【求助】请教 扩展JS 代码问题,谢谢各位大大!

楼主#
更多 发布于:2015-10-07 12:53
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 没有取到。
经常是只复制了标题,链接地址没有了,没有值。请问大大们,哪里出错了。找了没有找到。
闲云潭影日悠悠。物换星移几度秋了
游客

返回顶部