用createPopup作了一个模拟windows的菜单

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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() { window.alert("POWER BY BlueDestiny, never-online"); }
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>
posted on 2011-06-23 14:57  carekee  阅读(315)  评论(1编辑  收藏  举报