http://punchto.ufree.kr/php/etc/contextmenu.php

아래는 소스

오른족 버튼 눌렀을때 뜨는 contextMenu

<script>
var Menuover=0;
var menuTime = null;

d0cument.write('<style>.menuitem{color:black;height:18;text-indent:10;}</style><input type=text name=d0cumentURL style=width:0;height:0 style=position:absolute;>');
d0cument.onkeydown=menukey;
d0cument.onmousedown=menublur;
d0cument.oncontextmenu=onmenu;

function copyurl(){
d0cumentURL.value= d0cument.URL;
d0cumentURL.focus();
d0cumentURL.select();
range=d0cumentURL.createTextRange();
range.execCommand('Copy');
unmenu();
}

function onmenu(){
X = event.clientX;
Y = event.clientY;

if(!Menuover){
contextmenu.style.display='';
if(X<0 || Y<0 || X>d0cument.body.clientWidth || Y>d0cument.body.clientHeight){
contextmenu.style.display='none';
return true;
}

if(X+contextmenu.offsetWidth>d0cument.body.clientWidth){
contextmenu.style.left=(X+d0cument.body.scrollLeft-contextmenu.offsetWidth)-1;
}
elsecontextmenu.style.left=X+d0cument.body.scrollLeft-1;

if(Y+contextmenu.offsetHeight>d0cument.body.clientHeight && (Y-contextmenu.offsetHeight)>0){
contextmenu.style.top=(Y+d0cument.body.scrollTop-contextmenu.offsetHeight)-1;
}
elsecontextmenu.style.top = Y+d0cument.body.scrollTop-1;
}
clearTimeout(menuTime);
menuTimer();
return false;
}

function unmenu(){
contextmenu.style.display='none';
}
function menuover(){
Menuover=1;
clearTimeout(menuTime);
colorover();
}
function menuout(){
Menuover=0;
menuTimer();
colorout();
}
function menublur(){
if(!Menuover) unmenu();
}
function menuTimer(){
menuTime = setTimeout(unmenu,2000);
}
function colorover(){
if(event.srcElement.className=='menuitem'){
event.srcElement.style.background='0A246A';
event.srcElement.style.color='white'
}
}
function colorout(){
if(event.srcElement.className=='menuitem'){
event.srcElement.style.background='';
event.srcElement.style.color=''
}
}
function exec(){
if(event.srcElement.className=='menuitem'){
if(event.srcElement.href){
if(event.srcElement.target){
window.open(event.srcElement.href,event.srcElement.target);
}
else location.href=event.srcElement.href;
}
unmenu();
}
}
function menuline(){
d0cument.write("<tr><td><table cellpadding=0 cellspacing=0 width=100%><tr><td bgcolor=808080 height=1></td></tr><tr><td bgcolor=ffffff height=1></td></tr></table></td></tr>");
}
function menukey(){
if(contextmenu.style.display==''){
switch(event.keyCode){
case 66: history.go(-1); break;
case 79: history.go(1); break;
case 82: history.go(0); break;
case 70: window.external.AddFavorite(d0cument.URL, d0cument.title); break;
case 86: location.href='view-source:' + d0cument.URL;unmenu();break;
}
}
}
</script>

<div id=contextmenu style=display:none;position:absolute; onmouseover="menuover();" onmouseout="menuout();" onclick="exec();">
<table cellspacing=0 width=140 cellpadding=0 style=border-width:1;border-style:solid;border-top-color:D4D0C8;border-left-color:d4d0c8;border-right-color:404040;border-bottom-color:404040;><tr><td style=border-width:1;border-style:solid;border-top-color:ffffff;border-left-color:ffffff;border-right-color:808080;border-bottom-color:808080;>
<table bgcolor=D4D0C8 cellspacing=1 width=100% style=font-size:9pt;cursor:Default;>
<tr><td>

<tr><td class=menuitem valign=bottom href="javascript:history.go(-1)">뒤로(<u><font face=tahoma>B</font></u>)</td></tr>

<tr><td class=menuitem valign=bottom href="javascript:history.go(1)">앞으로(<u><font face=tahoma>O</font></u>)</td></tr>

<script>menuline();</script>

<tr><td class=menuitem valign=bottom href="http://daum.net" target="_self">다음넷(현재창)</td></tr>

<tr><td class=menuitem valign=bottom href="http://naver.com" target="_blank">네이버(새창)</td></tr>

<tr><td class=menuitem valign=bottom href="http://kr.yahoo.com" target="_blank">야후코리아(새창)</td></tr>

<script>menuline();</script>

<tr><td class=menuitem valign=bottom href="javascript:window.external.AddFavorite(d0cument.URL, d0cument.title)">즐겨찾기에 추가(<u><font face=tahoma>F</font></u>)</td></tr>

<tr><td class=menuitem valign=bottom href="javascript:location.href='view-source:' + d0cument.URL;unmenu()">소스보기(<u><font face=tahoma>V</font></u>)</td></tr>

<script>menuline();</script>

<tr><td class=menuitem valign=bottom href="javascript:history.go(0)">새로고침(<u><font face=tahoma>R</font></u>)</td></tr>

<script>menuline();</script>

<tr><td class=menuitem valign=bottom href="javascript:copyurl();">현재 주소 복사</td></tr>

</td></tr></table>
</td></tr></table>
</div>


● 마우스 오른쪽 버튼 클릭!!<br>

</body>

Posted by 퓨전마법사
,