[新着] Webテンプレートを仮オープンしました
//メニュークラス
function MenuUtil()
{
var obj_this = this;
//プルダウン表示
function pullDown(id)
{
obj_this.ids = id;
var elem = document.getElementById(id);
elem.style.visibility='visible';
document.body.onclick=closePullDown;
}
MenuUtil.prototype.pulldown = pullDown;
//プルダウンを閉じる
function closePullDown()
{
var elem = document.getElementById(obj_this.ids);
elem.style.visibility='hidden';
document.body.onclick = "";
ids = null;
}
MenuUtil.prototype.closePD = closePullDown;
return obj_this;
}function pullDown(id){
this.ids = id;
var elem = document.getElementById(id);
elem.style.visibility='visible';
var me = this;
document.body.onclick=function(e) {
me.closePD();
//closePullDown.call(me);
}
}<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">
#menu1,#menu2
{
position:relative;
width:90;
visibility:hidden;
hieght:200;
background-color:#ffffcc;
text-align:center;
}
</style>
<script type="text/javascript">
<!--
var menu = new MenuUtil();
//メニュークラス
function MenuUtil()
{
var list_elem = new Array();
var fn_click_old = document.documentElement.onclick;
document.documentElement.onclick = function()
{
if(fn_click_old != null)
fn_click_old.apply(this, arguments);
closePullDown();
};
//プルダウン表示
function pullDown(elem)
{
if(typeof(elem) == "string")
elem = document.getElementById(elem);
elem.style.visibility='visible';
list_elem.push(elem);
}
this.pulldown = pullDown;
//プルダウンを閉じる
function closePullDown()
{
var elem;
while(elem = list_elem.pop())
elem.style.visibility='hidden';
}
this.closePD = closePullDown;
}
//-->
</script>
<title>Menu練習</title>
</head>
<body>
<a href="#" onmouseover='menu.pulldown("menu1")'>menu1</a>
<div id="menu1">
<a href="http://www.aol.com">menu1-1</a> <a href="http://www.yahoo.co.jp">mennu1-2</a>
</div>
<a href="#" onmouseover='menu.pulldown("menu2")'>menu2</a>
<div id="menu2">
<a href="http://www.aol.com">menu2-1</a> <a href="http://www.yahoo.co.jp">mennu2-2</a>
</div>
</body>
</html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>Menu練習</title>
<style type="text/css">
#menu1, #menu2 {
position: relative;
width: 90px;
visibility: hidden;
height: 200px;
background-color: #ffc;
text-align: center;
}
</style>
<ul>
<li onmouseover="menu1.pullDown('menu1')">menu1
<ul id="menu1"><li>menu1-1</li><li>menu1-2</li></ul>
</li>
<li onmouseover="menu2.pullDown('menu2')">menu2
<ul id="menu2"><li>menu2-1</li><li>menu2-2</li></ul>
</li>
</ul>
<script type="text/javascript">
function MenuUtil () {
this.targetList = new Object;
this.init();
}
MenuUtil.prototype.init = function() {/*@cc_on*/
document.body.
/*@if (@_jscript) attachEvent('on' + @else@*/ addEventListener(/*@end@*/
'click',
(function(thisObj) { return function(e) { thisObj.closePullDown(); } } )(this),
false);
}
MenuUtil.prototype.pullDown = function(id) {
if ( ! this.targetList[id])
this.targetList[id] = document.getElementById(id);
this.targetList[id].style.visibility = 'visible';
}
MenuUtil.prototype.closePullDown = function() {
for (var id in this.targetList)
this.targetList[id].style.visibility = 'hidden';
}
var menu1 = new MenuUtil;
var menu2 = new MenuUtil;
</script>MenuUtil.prototype.init = function() {/*@cc_on*/
document.body.
/*@if (@_jscript) attachEvent('on' + @else@*/ addEventListener(/*@end@*/
'click',
(function(thisObj) { return function(e) { thisObj.closePullDown(); } } )(this),
false);
}MenuUtil.prototype.init = function() {
var thisObj = this;
document.body.attachEvent('onclick', function(x) { thisObj.closePullDown(); } );
}var C_Name = (function(Base) {
var private_static1 = 0;
var private_static2 = 0;
function main() { Base.call (this); }
main.prototype = new base;
return main;
function private1() { ; }
function private2() { ; }
} )(Base_C_Name);
var c = new C_Name;MenuUtil.prototype.init = function()
{
var thisObj = this;
document.documentElement./*@cc_on @if(@_jscript) attachEvent('on' + @else*/ addEventListener( /*@end@*/
'click', function(){ thisObj.closePullDown(); }, false);
}