DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> 用Popup對象構建網頁右鍵菜單
用Popup對象構建網頁右鍵菜單
編輯:關於JavaScript     

代碼如下:

   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<TITLE>Popup對象實現右鍵菜單</TITLE>
<script language="javascript">
var oPopup = window.createPopup();
function contextMenu()
{
   
    var left = event.offsetX+10;
    var top = event.offsetY+10;
    oPopup.document.body.innerHTML = oContext.innerHTML;
    oPopup.show(left, top, 120, 80, window.document.body);
   
}
</script>
</head>
<body oncontextmenu="contextMenu(); return false;">
<h1>Popup對象實現右鍵菜單</h1>
單擊鼠標右鍵查看效果
<div ID="oContext" style="DISPLAY: none; BACKGROUND: #e4e4e4; ">
    <div
        
       <span onclick='parent.location.href="http://www.zol.com.cn"'>
    中關村在線</span>
    </div>
    <div
        
    <span >
    電腦愛好者</span>
    </div>
    <div
         >
    <span >
    新浪網</span>
    </div>
    <div
        
    <span >
    新華網</span>
    </div>
   
</div>
</body>
</html>

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved