首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

关于在FRAMESET页面生成Popup菜单的有关问题

2012-02-02 
关于在FRAMESET页面生成Popup菜单的问题有一个代码a.html,用Popup生成右键菜单headtitleneverPopmenu-

关于在FRAMESET页面生成Popup菜单的问题
有一个代码a.html,用Popup生成右键菜单


<head>
  <title>   neverPopmenu   -   http://www.never-online.net   </title>
  <meta   http-equiv= "ImageToolbar "   content= "no "   />
  <meta   name= "author "   content= "BlueDestiny,   never-online "/>
  <meta   name= "keywords "   content= "Mozilla   CSS,   C#,   .net,   Refercence,   BlueDestiny,   never-online,   www.never-online.net "/>
  <meta   name= "description "   content= "BlueDestiny,   never-online "/>
  <meta   name= "title "   content= "Mozilla   CSS   Refercence   And   Demo   -   http://www.never-online.net "   />
  <meta   name= "creator.name "   content= "Genius   Lau,   never-online,   blueDestiny "   />
  <style   type= "text/css "   media= "all "   title= "Default ">

  </style>
  <script   type= "text/javascript ">
  // <![CDATA[
var   neverPopmenu=
{
    POP_OBJECT   :   window.createPopup(),
    POP_HEIGHT   :   190,
    POP_WIDTH   :   130,

    Html   :   " ",
    menuHtml   :   " ",
    headHtml   :   '\
        <html> \
        <head> \
        </head> \
        <style> \
        <!--\
        body   {   background-color:buttonface;   margin:0;   border:1px   outset   activeborder;margin:1px;}\
        .over   {   background-color:highlight;color:#fff;   }\
        .out   {   background-color:buttonface;color:000;   }\
        .hr   {   height:2px;   margin:0;   padding:0;   border:1px   inset;   overflow:hidden;   padding:4   0   4   0;   }\
        .underline   {   text-decoration:underline;   }\
        div   {   padding:4   0   4   20;cursor:default;   font:menu;   }\
        --> \
        </style> \
        <body   oncontextmenu= "event.returnValue=false "   onselectstart= "event.returnValue=false "   style= "overflow:hidden "> \
    ',
    footHtml   :   '\
        </body> \
        </html> \
    ',
    item   :   function(name,   shortcut,   handler,   disabled)   {
        if   (!name)   {
            neverPopmenu.menuHtml   +=   ' <div   class= "hr "> </div> ';
        }   else   {
            neverPopmenu.menuHtml   += '\
            <div   onmouseover= "this.className=\ 'over\ ' "   onmouseout= "this.className=\ 'out\ ' "   '   +(disabled   ?   "disabled=true "   :   'onclick=\ "this.className=\ 'out\ ';top.window. '+handler+ '() " ')+   '> '   +name+   '( <span   class= "underline "> '   +shortcut.toUpperCase()+   ' </span> ) </div> \


            ';
        }
    },
    init   :   function()   {
        var   doc   =   neverPopmenu.POP_OBJECT.document;
        neverPopmenu.Html   +=   neverPopmenu.headHtml   +   neverPopmenu.menuHtml   +   neverPopmenu.footHtml;
        doc.write(neverPopmenu.Html);
    },
    view   :   function()   {
        event.returnValue   =   false;
        neverPopmenu.POP_OBJECT.show(event.clientX,   event.clientY,   neverPopmenu.POP_WIDTH,   neverPopmenu.POP_HEIGHT,   document.body);
    }

}

function   handleName()   {
alert( "en ");
  }
function   handleBlog()   {   window.location.href= "http://blog.never-online.net ";   }
neverPopmenu.item( "查看 ",   "v ",   "handleName ");     //菜单名称、
neverPopmenu.item();
neverPopmenu.item( "排列图标 ",   "i ",   "handleName ");
neverPopmenu.item( "刷新 ",   "f ",   "handleName ");
//neverPopmenu.item();
neverPopmenu.item( "粘贴 ",   "v ",   "handleName ",   1);
neverPopmenu.item( "粘贴快捷方式 ",   "s ",   "handleName ",   1);
neverPopmenu.item();
neverPopmenu.item( "新建 ",   "w ",   "handleName ");
neverPopmenu.item();
neverPopmenu.item( "属性 ",   "r ",   "handleName ");
neverPopmenu.item();
neverPopmenu.item( "博客 ",   "b ",   "handleBlog ");
onload=neverPopmenu.init;


  </script>
</head>
<body   id= "www.never-online.net "   oncontextmenu= "neverPopmenu.view() ">

</body>
</html>

测试菜单功能,弹出和调用javascript函数都没有问题。

可是当我把a.html页面放入b.html

b.html用了frame框架,代码如下:
<FRAMESET   name= "Cm "   cols= "120,* "     frameborder=1   framespacing=1   bgcolor=#e1f3fd     bordercolor=DarkSlateGray>
                              <FRAME   name= "c "   id= "c "   src= "c.htm "   target= "main "   FRAMESPACING= "0 "   border= "0 "   frameborder= "0 "   scrolling= "no "   noresize   valign=top>
            <FRAME   name= "a "   id= "a "   src= "a.htm "   target= "main "   FRAMESPACING= "0 "   border= "0 "   frameborder= "0 "   scrolling= "no "   noresize   valign=top>
 
</FRAMESET>

问题就出来了,运行b.html的时候,框架里面a的菜单是可以出来,但是调用javascript的时候总提示:“对象不支持此属性或者方法“

请问这是怎么回事?需要怎么改动?
谢谢~~~



[解决办法]
看看
[解决办法]
那么复杂,调试一下咯~~~
[解决办法]
'onclick=\ "this.className=\ 'out\ ';top.window. '+handler+ '() " ')+ '


其中
top.window.[expression]
改成
parent.[expression]看看。
呵呵,精神不好,看不太明白。
估计是嵌套不对。
[解决办法]
原来是这样

'onclick=\ "this.className=\ 'out\ ';top.window. '+handler+ '() " '

单击时调用top.window.handler,调用最外层框架的handler函数

单个页面时无问题
当你放在框架里了,最外层是框架集,自然没有handler函数,自然出错
直接用window.handler就好
如果要跨框架调用popmenu
考虑好框架名
[解决办法]
比如你这个框架集,
b里头要调用a的函数就是a.fun()
c调a的就是parent.a.fun()
类推。。。。。。。


------------
偷偷溜回web版来看看,罪过罪过~~~~~~~~~~

热点排行