<< db4o 面向对象数据库的安装使用 | 首页 | Use the Java concurrency API to speed up time-consuming tasks >>

在网页中用iframe做下拉菜单盖住select下拉框

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>runcode</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Author" content="Sheneyan" />
<script type="text/javascript">
function initBK(){
var o = document.createElement('iframe');
o.id = 'fram_bk';
document.body.appendChild(o);
}
function popMenu(e){
var o = window.event?event.srcElement:e.target;
var p = getXY(e);
if (document.all){
if (!$('fram_bk')){initBK();}
with ($('fram_bk').style){
display='block';
top = p.y+"px";
left = p.x+"px";
}
}
with ($('menu').style){
display='block';
top = p.y+"px";
left = p.x+"px";
}
}
function getXY(e){
var posx=0,posy=0;
if(e==null) e=window.event;
if(e.pageX || e.pageY){
posx=e.pageX; posy=e.pageY;
}
else if(e.clientX || e.clientY){
if(document.documentElement.scrollTop){
posx=e.clientX+document.documentElement.scrollLeft;
posy=e.clientY+document.documentElement.scrollTop;
}
else{
posx=e.clientX+document.body.scrollLeft;
posy=e.clientY+document.body.scrollTop;
}
}
return {x:posx,y:posy};
}
function $(id){return document.getElementById(id)}
</script>
<style type="text/css">
div#menu{display:none;position:absolute;width:200px;height:300px;z-index:100;background:yellow;}
iframe#fram_bk{border:0;position:absolute;display:none;z-index:0;width:200px;height:300px;}
</style>
</head>
<body>
<button onclick="popMenu(event)">弹出菜单</button><br />
<div id="menu">
<ul>
<li><a href="?">这里真的是菜单</a></li>
<li><a href="?">别看这里没内容</a></li>
<li><a href="?">我真的把它当菜单</a></li>
<li><a href="?">这里真的是菜单</a></li>
</ul>
</div>
<select><option>这是select哦</option></select>
</body>
</html>

看看效果:




发表评论 发送引用通报