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

notata 2007-03-08 10:50:15
有一个代码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的时候总提示:“对象不支持此属性或者方法“

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

...全文
523 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
qj_198127 2008-09-26
  • 打赏
  • 举报
回复
this.ole_ie.object.document.f_execute_sql.query.click()
f_execute_sql是表单名称,query是按钮名称
notata 2007-03-12
  • 打赏
  • 举报
回复
谢谢大家,我现在改用层菜单,目前还没有时间调试,等回头调试好了再结贴。:)
showlin 2007-03-11
  • 打赏
  • 举报
回复
比如你这个框架集,
b里头要调用a的函数就是a.fun()
c调a的就是parent.a.fun()
类推。。。。。。。


------------
偷偷溜回web版来看看,罪过罪过~~~~~~~~~~
showlin 2007-03-11
  • 打赏
  • 举报
回复
原来是这样

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

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

单个页面时无问题
当你放在框架里了,最外层是框架集,自然没有handler函数,自然出错
直接用window.handler就好
如果要跨框架调用popmenu
考虑好框架名
xuStanly 2007-03-11
  • 打赏
  • 举报
回复
'onclick=\"this.className=\'out\';top.window.'+handler+'()"')+ '
其中
top.window.[expression]
改成
parent.[expression]看看。
呵呵,精神不好,看不太明白。
估计是嵌套不对。
silentwins 2007-03-09
  • 打赏
  • 举报
回复
那么复杂,调试一下咯~~~
cloudgamer 2007-03-08
  • 打赏
  • 举报
回复
看看

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧