zoukankan      html  css  js  c++  java
  • 博客园网摘IE插件源码分析

    1.文件AddScript.reg添加IE右键菜单

    REGEDIT4

    [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt]

    [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\◎ 收藏此页到【博客园网摘】]

    @="http://home.cnblogs.com/wz/rightclick/"

     

    2.文件Remove.reg删除IE右键菜单

    REGEDIT4

    [-HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\◎ 收藏此页到【博客园网摘】]

     

    3.IE浏览器输入http://home.cnblogs.com/wz/rightclick/,查看源码

     <html>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     <script language="JavaScript"> 


        //如果是拓展菜单事件,则执行以下代码
        if (external.menuArguments) {
            var parentwin = external.menuArguments;
            if (parentwin.document.selection) {
                var sel = parentwin.document.selection.createRange().text;
            }      
            if (!sel) {
                var sel = '';
            }


            //获得右键页面的URL
            var url = parentwin.document.URL;

            //获得右键页面的title

            var title = parentwin.document.title;
            var i = 0;       

            //如果鼠标在A标签上
            if (parentwin.event.srcElement.tagName == "A") {
                url = parentwin.event.srcElement.getAttribute("HREF");
                title = parentwin.event.srcElement.innerText;
            } 

            //如果鼠标在IMG标签上
            if (parentwin.event.srcElement.tagName == "IMG") {
                url = parentwin.event.srcElement.getAttribute("SRC");
                if (parentwin.event.srcElement.getAttribute("ALT") != null && parentwin.event.srcElement.getAttribute("ALT") != "") {
                    title = parentwin.event.srcElement.getAttribute("ALT");
                }
                i = 1
            }       

            //打开新的IE窗口
            void (window.open('http://wz.cnblogs.com/create?t=' + encodeURIComponent(title) + '&u=' + encodeURIComponent(url) + '&c=' +  encodeURIComponent(sel) + '&i=' + i, '_blank', 'scrollbars=auto,width=460,height=353,left=100,top=50,status=yes,resizable=yes'))
        } else {

            //返回
            history.go(-1);
        }
    </script>
    </html>

    --OVER

     

  • 相关阅读:
    种子销售管理需求
    三角函数
    软件人性化的体现
    三角函数
    ProductManager
    不能说的秘密
    种子销售管理需求
    JTable使用
    不能说的秘密
    设计模式(了解篇)转载
  • 原文地址:https://www.cnblogs.com/zhuri/p/2670766.html
Copyright © 2011-2022 走看看