인터넷정보

마우스 오른쪽 클릭시 컨텍스트 메뉴(context menu)

알 수 없는 사용자 2007. 10. 18. 13:47

http://oxtag.com/html/ex/mouse/mouse_context/mouse2.htm

<!--


// 마우스 오른쪽버튼 메뉴

var isIE = 0;
if(window.navigator.appName == 'Microsoft Internet Explorer' && window.navigator.appVersion.substring(window.navigator.appVersion.indexOf('MSIE') + 5,window.navigator.appVersion.indexOf('MSIE') + 8) >= 5.5) {
 isIE = 1;
} else {
 isIE = 0;
}
if(isIE) {
 var HTML = "<table width=100% bgcolor=white border=0 cellpadding=0 cellspacing=0 style='font-family:굴림;font-size:9pt;color:#323232;border:1 #323232 solid;cursor:default' ";
 HTML += "onContextMenu='return false' onDragStart='return false' onSelectStart='return false' onMouseUp='parent.nContext.show(0,0,document.body)'>\n";
 HTML += "<tr><td height=23 align=center bgcolor=#969696 onMouseUp=\"alert('http://oxtag.com/')\"><img src='./img/c_title.gif' width=113 height=15 align=middle border=0 alt='컨텍스트 메뉴입니다. ^-^;'></td></tr>\n";
 HTML += "<tr height=23 style='padding-top:3' onMouseOver=\"this.style.backgroundColor='#cccccc'\" onMouseOut=\"this.style.backgroundColor=''\" title='이전 페이지로 이동'>\n";
 HTML += "<td onMouseUp='parent.history.go(-1)'><img src='./img/c_back.gif' width=9 height=9 align=middle border=0 hspace=7>뒤로</td></tr>\n";
 HTML += "<tr height=1><td background='./img/dot_b.gif'></td></tr>";
 HTML += "<tr height=23 style='padding-top:3' onMouseOver=\"this.style.backgroundColor='#cccccc'\" onMouseOut=\"this.style.backgroundColor=''\" title='앞 페이지로 이동'>\n";
 HTML += "<td onMouseUp='parent.history.go(1)'><img src='./img/c_fwd.gif' width=9 height=9 align=middle border=0 hspace=7>앞으로</td></tr>\n";
 HTML += "<tr height=1><td background='./img/dot_b.gif'></td></tr>";
 HTML += "<tr height=23 style='padding-top:3' onMouseOver=\"this.style.backgroundColor='#cccccc'\" onMouseOut=\"this.style.backgroundColor=''\" title='태그피아 홈페이지를 즐겨찾기에 추가'>\n";
 HTML += "<td onMouseUp=\"window.external.AddFavorite('http://oxtag.com/','♡ 카멜롯™의 소스천국 태그피아 ♡');\"><img src='./img/c_fav.gif' width=9 height=9 align=middle border=0 hspace=7>즐겨찾기에 추가</td></tr>\n";
 HTML += "<tr height=1><td background='./img/dot_b.gif'></td></tr>";
 HTML += "<tr height=23 style='padding-top:3' onMouseOver=\"this.style.backgroundColor='#cccccc'\" onMouseOut=\"this.style.backgroundColor=''\" title='현재 페이지를 인쇄합니다.'>\n";
 HTML += "<td onMouseUp='parent.print()'><img src='./img/c_print.gif' width=9 height=9 align=middle border=0 hspace=7>인쇄</td></tr>\n";
 HTML += "<tr height=1><td background='./img/dot_b.gif'></td></tr>";
 HTML += "<tr height=23 style='padding-top:3' onMouseOver=\"this.style.backgroundColor='#cccccc'\" onMouseOut=\"this.style.backgroundColor=''\" title='현재 페이지를 새로 고칩니다.'>\n";
 HTML += "<td onMouseUp='parent.location.reload()'><img src='./img/c_reld.gif' width=9 height=9 align=middle border=0 hspace=7>새로 고침</td></tr>\n";
 HTML += "<tr height=1><td bgcolor=#646464></td></tr>";
 HTML += "<tr height=23 style='padding-top:3' onMouseOver=\"this.style.backgroundColor='#cccccc'\" onMouseOut=\"this.style.backgroundColor=''\" title='현재 페이지 내용을 모두 선택합니다.'>\n";
 HTML += "<td onMouseUp='parent.selectAll()'><img src='./img/c_sele.gif' width=9 height=9 align=middle border=0 hspace=7>모두 선택</td></tr>\n";
 HTML += "<tr height=1><td background='./img/dot_b.gif'></td></tr>";
 HTML += "<tr height=23 style='padding-top:3' onMouseOver=\"this.style.backgroundColor='#cccccc'\" onMouseOut=\"this.style.backgroundColor=''\" title='선택한 영역을 복사합니다.'>\n";
 HTML += "<td onMouseUp='parent.copyText()'><img src='./img/c_copy.gif' width=9 height=9 align=middle border=0 hspace=7>복사</td></tr>\n";
 HTML += "<tr height=1><td background='./img/dot_b.gif'></td></tr>";
 HTML += "<tr height=23 style='padding-top:3' onMouseOver=\"this.style.backgroundColor='#cccccc'\" onMouseOut=\"this.style.backgroundColor=''\" title='클립보드 내용을 붙여넣습니다.'>\n";
 HTML += "<td onMouseUp='parent.pasteText()'><img src='./img/c_paste.gif' width=9 height=9 align=middle border=0 hspace=7>붙여넣기</td></tr>\n";
 HTML += "<tr height=1><td background='./img/dot_b.gif'></td></tr>";
 HTML += "<tr height=23 style='padding-top:3' onMouseOver=\"this.style.backgroundColor='#cccccc'\" onMouseOut=\"this.style.backgroundColor=''\" title='선택한 텍스트를 강조합니다.'>\n";
 HTML += "<td onMouseUp='parent.highlightText()'><img src='./img/c_hlight.gif' width=9 height=9 align=middle border=0 hspace=7>강조</td></tr>\n";
 HTML += "<tr height=1><td background='./img/dot_b.gif'></td></tr>";
 HTML += "<tr height=23 style='padding-top:3' onMouseOver=\"this.style.backgroundColor='#cccccc'\" onMouseOut=\"this.style.backgroundColor=''\" title='선택한 텍스트를 검색합니다. (네이버)'>\n";
 HTML += "<td onMouseUp='parent.searchText()'><img src='./img/c_srch.gif' width=9 height=9 align=middle border=0 hspace=7>단어 검색</td></tr>\n";
 // HTML +='<TR><TD STYLE="border:0pt solid #FFFFFF" ID="i8" ONMOUSEOVER="document.all.i8.style.background=\'#FFFFFF\';document.all.i8.style.border=\'0pt solid #737B92\';" ONMOUSEOUT="document.all.i8.style.background=\'\';document.all.i0.style.border=\'0pt solid #CCCCCC\';" ONCLICK="if(window.parent.document.body.style.zoom!=0) window.parent.document.body.style.zoom*=1.6; else window.parent.document.body.style.zoom=1.6;"> <img SRC="./img/menuzoom.gif" WIDTH="12" HEIGHT="12" BORDER="0" HSPACE="0" VSPACE="0" ALIGN="absmiddle"> 확대해서보기</TD></TR>';
 // HTML +='<TR><TD STYLE="border:0pt solid #FFFFFF" ID="i9" ONMOUSEOVER="document.all.i9.style.background=\'#FFFFFF\';document.all.i9.style.border=\'0pt solid #737B92\';" ONMOUSEOUT="document.all.i9.style.background=\'\';document.all.i0.style.border=\'0pt solid #CCCCCC\';" ONCLICK="if(window.parent.document.body.style.zoom!=0) window.parent.document.body.style.zoom*=0.625; else window.parent.document.body.style.zoom=0.625;"> <img SRC="./img/menuzoom.gif" WIDTH="12" HEIGHT="12" BORDER="0" HSPACE="0" VSPACE="0" ALIGN="absmiddle"> 축소해서보기</TD></TR>';
 HTML += "</table>";
 var nContext = window.createPopup();
}

function dnContext(x,y) {
 if(isIE) {
  var nContextBody = nContext.document.body;
  nContextBody.innerHTML = HTML;
  nContext.show(x,y,140,264,document.body);
 }
}

function showContext(e) {
 if(isIE) {
  if(document.all) {
   if(event.button == 2 || event.button == 3) {
    dnContext(event.x,event.y);
   }
  }
 }
}

if(isIE) {
 document.oncontextmenu = function() {
  dnContext(event.x,event.y);
  return false;
 }
 document.onmouseclick = showContext;
}


// 마우스 오른쪽버튼 메뉴용 보조 도구

function selectAll() {
 document.body.createTextRange().select();
}

function copyText() {
 var sel = document.selection;
 var rng = sel.createRange();
 rng.execCommand('Copy');
}

function pasteText() {
 var sel = document.selection;
 var rng = sel.createRange();
 rng.execCommand('Paste');
 // alert(' 아직 스크립트가 불완전하여 구현되지 않습니다. \n\n    Windows 붙여넣기 단축키는 [Ctrl + V] 입니다.');
}

function highlightText() {
 var sel = document.selection;
 var rng = sel.createRange();
 var str = new String(rng.text);
 if (str == '') {
  alert(' 강조할 영역이 선택되지 않았습니다. \n\n    강조할 영역(텍스트)를 긁으세요.');
 } else {
  rng.execCommand('BackColor',0,'yellow');
 }
}

function searchText() {
 var sel = document.selection;
 var rng = sel.createRange();
 var str = new String(rng.text);
 var searchWin = new String('http://search.naver.com/search.naver?where=nexearch&query=' + str);
 if (str == '') {
  alert(' 검색할 단어가 없습니다. \n\n 먼저 텍스트를 긁으세요. ');
 } else {
  window.open(searchWin);
 }
}


//-->

반응형