<body>
<style><!--.skin0 {position:absolute;text-align:left;width:200px;border:2px solid black;background-color:menu;font-family:Verdana;line-height:20px;cursor:default;visibility:hidden;}.skin1 {cursor:default;font:menutext;position:absolute;text-align:left;font-family: Arial, Helvetica, sans-serif;font-size: 10pt;width:120px;background-color:menu;border:1 solid buttonface;visibility:hidden;border:2 outset buttonhighlight;}.menuitems {padding-left:15px;padding-right:10px;}--></style><SCRIPT LANGUAGE="JavaScript1.2"><!-- Web Site: http://www.painting-effects.co.uk --><!-- This script and many more are available free online at --><!-- The JavaScript Source!! http://javascript.internet.com --><!-- Beginvar menuskin = "skin1"; // skin0, or skin1var display_url = 0; // Show URLs in status bar?function showmenuie5() {var rightedge = document.body.clientWidth-event.clientX;var bottomedge = document.body.clientHeight-event.clientY;if (rightedge < ie5menu.offsetWidth)ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;elseie5menu.style.left = document.body.scrollLeft + event.clientX;if (bottomedge < ie5menu.offsetHeight)ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;elseie5menu.style.top = document.body.scrollTop + event.clientY;ie5menu.style.visibility = "visible";return false;}function hidemenuie5() {ie5menu.style.visibility = "hidden";}function highlightie5() {if (event.srcElement.className == "menuitems") {event.srcElement.style.backgroundColor = "highlight";event.srcElement.style.color = "white";if (display_url)window.status = event.srcElement.url; }}function lowlightie5() {if (event.srcElement.className == "menuitems") {event.srcElement.style.backgroundColor = "";event.srcElement.style.color = "black";window.status = ""; }}function jumptoie5() {if (event.srcElement.className == "menuitems") {if (event.srcElement.getAttribute("target") != null)window.open(event.srcElement.url, event.srcElement.getAttribute("target"));elsewindow.location = event.srcElement.url; }}// End --></script><div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5();"><div class="menuitems" url="javascript:history.back();">返回</div><div class="menuitems" url="http://javacool.3322.net">回首页</div><hr><div class="menuitems" url="http://www.163.com">网易</div><div class="menuitems" url="http://www.sohu.com">搜狐</div><hr><div class="menuitems" url="http://www.sina.com.cn">新浪</div><div class="menuitems" url="http://www.yahoo.com.cn">雅虎</div></div><script language="JavaScript1.2">if (document.all && window.print) {ie5menu.className = menuskin;document.oncontextmenu = showmenuie5;document.body.onclick = hidemenuie5;}</script>
</body>
<style><!--.skin0 {position:absolute;text-align:left;width:200px;border:2px solid black;background-color:menu;font-family:Verdana;line-height:20px;cursor:default;visibility:hidden;}.skin1 {cursor:default;font:menutext;position:absolute;text-align:left;font-family: Arial, Helvetica, sans-serif;font-size: 10pt;width:120px;background-color:menu;border:1 solid buttonface;visibility:hidden;border:2 outset buttonhighlight;}.menuitems {padding-left:15px;padding-right:10px;}--></style><SCRIPT LANGUAGE="JavaScript1.2"><!-- Web Site: http://www.painting-effects.co.uk --><!-- This script and many more are available free online at --><!-- The JavaScript Source!! http://javascript.internet.com --><!-- Beginvar menuskin = "skin1"; // skin0, or skin1var display_url = 0; // Show URLs in status bar?function showmenuie5() {var rightedge = document.body.clientWidth-event.clientX;var bottomedge = document.body.clientHeight-event.clientY;if (rightedge < ie5menu.offsetWidth)ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;elseie5menu.style.left = document.body.scrollLeft + event.clientX;if (bottomedge < ie5menu.offsetHeight)ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;elseie5menu.style.top = document.body.scrollTop + event.clientY;ie5menu.style.visibility = "visible";return false;}function hidemenuie5() {ie5menu.style.visibility = "hidden";}function highlightie5() {if (event.srcElement.className == "menuitems") {event.srcElement.style.backgroundColor = "highlight";event.srcElement.style.color = "white";if (display_url)window.status = event.srcElement.url; }}function lowlightie5() {if (event.srcElement.className == "menuitems") {event.srcElement.style.backgroundColor = "";event.srcElement.style.color = "black";window.status = ""; }}function jumptoie5() {if (event.srcElement.className == "menuitems") {if (event.srcElement.getAttribute("target") != null)window.open(event.srcElement.url, event.srcElement.getAttribute("target"));elsewindow.location = event.srcElement.url; }}// End --></script><div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5();"><div class="menuitems" url="javascript:history.back();">返回</div><div class="menuitems" url="http://javacool.3322.net">回首页</div><hr><div class="menuitems" url="http://www.163.com">网易</div><div class="menuitems" url="http://www.sohu.com">搜狐</div><hr><div class="menuitems" url="http://www.sina.com.cn">新浪</div><div class="menuitems" url="http://www.yahoo.com.cn">雅虎</div></div><script language="JavaScript1.2">if (document.all && window.print) {ie5menu.className = menuskin;document.oncontextmenu = showmenuie5;document.body.onclick = hidemenuie5;}</script>
</body>
解决方案 »
- jscript正则是否支持lookbehind方式,活着自定义match方式
- IE下在file input上点击回车键,为何无法弹出对话框?
- 用js获取源代码的问题
- PHP 相片移动问题
- JQUERY的问题
- 在javascript中的单元格中怎样设置字体出现在单元格的上部?
- 如何用js来取得类似asp中的Request.ServerVariables("HTTP_REFERER")的值呀
- 求树状菜单源码,哪位大哥手头有给一份,谢谢~!
- 表单颜色的设置问题,在线等!!
- <tr>在客户端脚本里怎么调用!
- 小问题,请精通css的大虾回答
- 这是一个网上在线考试的网页,有填空题,现在的问题是只用javascript来实现
<HTML><HEAD><TITLE>自定义鼠标右键弹出式菜单</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>.p9 {
FONT-SIZE: 12px; LINE-HEIGHT: 120%
}
.title {
FONT-SIZE: 25px
}
.div1 {
BORDER-RIGHT: windowframe 1px solid; BORDER-TOP: buttonface 1px solid; BORDER-LEFT: buttonface 1px solid; BORDER-BOTTOM: windowframe 1px solid
}
.div2 {
BORDER-RIGHT: buttonshadow 1px solid; BORDER-TOP: window 1px solid; BORDER-LEFT: window 1px solid; BORDER-BOTTOM: buttonshadow 1px solid
}
.Mover {
FONT-SIZE: 12px; CURSOR: default; COLOR: highlighttext; BACKGROUND-COLOR: highlight
}
.Mout {
FONT-SIZE: 12px; CURSOR: default; COLOR: buttontext; BACKGROUND-COLOR: buttonface
}
TD {
FONT-SIZE: 14px
}
SELECT {
FONT-SIZE: 14px
}
BODY {
FONT-SIZE: 14px
}
A {
TEXT-DECORATION: none
}
A:hover {
COLOR: #ff0000; TEXT-DECORATION: underline
}
</STYLE><SCRIPT language=javascript>
function PopupMouseRightButtonUpMenu(){
if(MouseMenu.style.visibility=='visible') MouseMenu.style.visibility='hidden';
if(event.srcElement.tagName=='A' || event.srcElement.tagName=='TEXTAREA' || event.srcElement.tagName=='INPUT' || oSelection.type!='None')
return true;
else{
if(event.clientX+150 > document.body.clientWidth)MouseMenu.style.left=event.clientX+document.body.scrollLeft-150;
else MouseMenu.style.left=event.clientX+document.body.scrollLeft;
if(event.clientY+DivH > document.body.clientHeight)MouseMenu.style.top=event.clientY+document.body.scrollTop-DivH;
else MouseMenu.style.top=event.clientY+document.body.scrollTop;
MouseMenu.style.visibility='visible';
}
return false;
}
function DrawMouseRightButtonUpMenu(){
DivH=2;
oSelection = document.selection;var HrStr='<tr><td align=\"center\" valign=\"middle\" height=\"2\"><TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"128\" height=\"2\"><tr><td height=\"1\" bgcolor=\"buttonshadow\"><\/td><\/tr><tr><td height=\"1\" bgcolor=\"buttonhighlight\"><\/td><\/tr><\/TABLE><\/td><\/tr>';
var MenuStr1='<tr><td align=\"center\" valign=\"middle\" height=\"20\"><TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"132\"><tr><td valign=\"middle\" height=\"16\" class=\"Mout\" onMouseOver=\"this.className=\'Mover\'\" onMouseOut=\"this.className=\'Mout\'\" onclick=\"'
var MenuStr2="<\/td><\/tr><\/TABLE><\/td><\/tr>";
var historyMenu=['window.history.back()\">后退','window.history.forward()\">前进'];
var SysMenu=['\">查找 <INPUT TYPE=\"text\" Size=\"10\" onkeypress=\"if (event.keyCode == 13) {MouseMenu.style.visibility=\'hidden\';var temp = this.value; this.value = \'\';return findInPage(temp)}\";\'>',
'document.execCommand(\'SelectAll\')\">全选',
'MouseMenu.style.visibility=\'hidden\';document.execCommand(\'SaveAs\',\'true\')\">另存为 ...',
'location.replace(\'view-source:\'+location.href)\">查看源文件',
'window.print()\">打印',
'window.location.reload()\">刷新'];
var MenuStr='';
for(i=0;i<historyMenu.length;i++){
MenuStr+=MenuStr1+historyMenu[i]+MenuStr2;
DivH+=20;
}
MenuStr+=HrStr;
for(i=0;i<arguments.length;i++){
MenuStr+=MenuStr1+arguments[i]+MenuStr2;
DivH+=20;
}
if(arguments.length>0){
MenuStr+=HrStr;
DivH+=2;
}
for(i=0;i<SysMenu.length;i++){
MenuStr+=MenuStr1+SysMenu[i]+MenuStr2;
DivH+=20;
}
var DivStr1='<DIV id=\"MouseMenu\" class=\"div1\" style=\"position:absolute; left:0px; top:0px; width=150;height='+DivH+'; z-index:1; visibility:hidden;\"><TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"div2\"><tr><td bgcolor=\"'+TableColor+'\" width=\"50\" valign=\"bottom\" align=\"center\" bgcolor=\"buttonface\"><\/td><td bgcolor=\"buttonface\"><TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\">';
var DivStr2="<\/TABLE><\/td><\/tr><\/TABLE><\/DIV>";
document.write(DivStr1+MenuStr+DivStr2);
document.body.oncontextmenu=new Function('return PopupMouseRightButtonUpMenu();');
document.body.onclick=new Function('if(event.srcElement.tagName !=\'INPUT\') MouseMenu.style.visibility=\'hidden\'');
document.body.onscroll=new Function('MouseMenu.style.visibility=\'hidden\';');
document.body.onselectstart=new Function('MouseMenu.style.visibility=\'hidden\';');
window.onresizestart=new Function('MouseMenu.style.visibility=\'hidden\';');
}
var NS4 = (document.layers);
var IE4 = (document.all);
var win = window;
var n = 0;
function findInPage(str) {
var txt, i, found;
if (str == "")
return false;
if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0)
alert("Not found.");
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else {
if (n > 0) {
n = 0;
findInPage(str);
}
else
alert("文档搜索完毕!");
}
} return false;
}
</SCRIPT><META content="MSHTML 6.00.2719.2200" name=GENERATOR></HEAD>
<BODY>自定义鼠标右键弹出式菜单
<SCRIPT language=javascript>
TableColor='#3300FF';
DrawMouseRightButtonUpMenu()
</SCRIPT>
<INPUT onclick="javascript:document.execCommand('saveas','ture')" type=button value=test name=test>
</BODY></HTML>