js 创建一个浮动div的代码
作者:bea
<body> <script> //关闭DIV MENU function MenuClose() { var MenuDiv = document.getElementById("MenuDiv"); if(MenuDiv != null) { document.body.removeChild(MenuDiv); } } //创建menu function MenuPanel(opflag,operid, left, top) { var Men
<body>
<script>
//关闭DIV MENU
function MenuClose()
{
var MenuDiv = document.getElementById("MenuDiv");
if(MenuDiv != null)
{
document.body.removeChild(MenuDiv);
}
}
//创建menu
function MenuPanel(opflag,operid, left, top)
{
var MenuDiv = document.getElementById("MenuDiv");
if(MenuDiv != null)
{
document.body.removeChild(MenuDiv);
}
var useflag = "停用帐号";
var flag=opflag;
if (flag == "0")
{
useflag = "停用帐号";
}
else
{
useflag = "激活帐号";
}
MenuDiv = document.createElement("div");
MenuDiv.id = "MenuDiv";
MenuDiv.onmouseleave = function()
{
MenuClose();
}
MenuDiv.style.position = "absolute";
MenuDiv.style.setAttribute("zIndex" ,"201");
MenuDiv.style.setAttribute("backgroundColor" ,"#EFEFEF");
MenuDiv.style.setAttribute("Font" ,"10pt");
MenuDiv.style.setAttribute("width" ,60);
MenuDiv.style.setAttribute("left" ,left);
MenuDiv.style.setAttribute("top" ,top);
MenuDiv.innerHTML = "<table width="100%">"
+"<tr><td onclick="javascript:RedirectUrl(1,'" + flag + "','" + operid + "');MenuClose();" style="cursor:hand;height:20px;Color:blue;" onmouseover="this.style.backgroundColor='#FFD76B';" onmouseout="this.style.backgroundColor='#EFEFEF';" align="left" valign="top">"+useflag+"</td></tr>"
+"<tr><td onclick="RedirectUrl(0,0,'" + operid + "')" style="cursor:hand;height:20px;Color:blue;" onmouseover="this.style.backgroundColor='#FFD76B';" onmouseout="this.style.backgroundColor='#EFEFEF';" align="left" valign="top">修改帐号</td></tr>"
+"<tr><td onclick="javascript:RedirectUrl(4,0,'" + operid + "')" style="cursor:hand;height:20px;Color:blue;" onmouseover="this.style.backgroundColor='#FFD76B';" onmouseout="this.style.backgroundColor='#EFEFEF';" align="left" valign="top">重设密码</td></tr>"
+"<tr><td onclick="RedirectUrl(2,0,'" + operid + "')" style="cursor:hand;height:20px;Color:blue;" onmouseover="this.style.backgroundColor='#FFD76B';" onmouseout="this.style.backgroundColor='#EFEFEF';" align="left" valign="top">角色管理</td></tr>"
+"<tr><td onclick="javascript:RedirectUrl(3,0,'" + operid + "')" style="cursor:hand;height:20px;Color:blue;" onmouseover="this.style.backgroundColor='#FFD76B';" onmouseout="this.style.backgroundColor='#EFEFEF';" align="left" valign="top">删除帐号</td></tr>"
+"</table>";
document.body.appendChild(MenuDiv);
}
//获取控件的高度和宽度
function getAbsolutePos(e)
{
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent)
{
t+=e.offsetTop;
l+=e.offsetLeft;
}
var pos = { x: l, y: t };
return pos;
}
</script>
<div id="net" onclick="MenuPanel()">代码测试(点击选择)</div>
</body>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行]
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- javascript 动态调整图片尺寸实现代码
- jquery $(document).ready() 与window.onload的区别
- jQuery的强大选择器小结
- IE6 弹出Iframe层中的文本框“经常”无法获得输入焦点
- JavaScript 拾漏补遗
- js 实现无干扰阴影效果 简单好用(附文件下载)
- 向大师们学习Javascript(视频与PPT)
- javascript+css 网页每次加载不同样式的实现方法
- 用Jquery实现可编辑表格并用AJAX提交到服务器修改数据
- jQuery中的常用事件总结
- jQuery 动态酷效果实现总结
- javascript dom操作之cloneNode文本节点克隆使用技巧
- javascript 格式化时间日期函数代码
- javascript 清空form表单中某种元素的值
- JavaScript 入门基础知识 想学习js的朋友可以参考下
- 十分钟打造AutoComplete自动完成效果代码
- jQuery 常见开发使用技巧总结
- javascript 最常用的10个自定义函数[推荐]
- javascript下利用数组缓存正则表达式的实现方法