码迷,mamicode.com
首页 > Web开发 > 详细

html 浮动窗口

时间:2015-03-10 12:18:07      阅读:352      评论:0      收藏:0      [点我收藏+]

标签:

		<input type="text" size="84" id="receiver"/>
		<input type="button" value="批量输入" onclick="createInputDialog(this,'1','')" name="riskbehavior"/>	


function createInputDialog(obj,id,value)
{  
    var div=document.getElementById("editBehaviorDiv");  
    if(div!=null)  
        document.body.removeChild(div);  
    div = document.createElement("div");   
    div.id="editBehaviorDiv";  
    div.style.position='absolute';  
    var op=getoffset(obj); 
    div.style.top= "100px";  
    div.style.left= (document.body.clientWidth - 374)/2.0 + "px";  
    div.style.zIndex =100;  
    div.style.backgroundColor='#ecf1f6';  
    div.style.border="1px solid #666";  
    //div.className="td1";  
    div.innerHTML="<textarea name='behaviorValue' id='behaviorValue' cols='50' rows='8'>"+value+  
    "</textarea><br/><input type='button' value='修改' onclick=\"saveBehaviorname(this.parentNode,'"+id+"')\" />"+  
    "<input type='button' value='取消' id='cancelButton' onclick='document.body.removeChild(this.parentNode);'/>";  
    document.body.appendChild(div);  
    document.all.behaviorValue.focus();  
}   

function saveBehaviorname(obj,id)
{
    var behaviorValue = document.all.behaviorValue.value;
    var idsArray = new Array(); //定义一数组 
    idsArray = behaviorValue.split("\n"); //字符分割
    var idsString = "";
    for (i = 0; i < idsArray.length; i++) 
    { 
    	var temp = idsArray[i].Trim();
    	if(temp != null && temp != "")
    	{
    		idsString = idsString + idsArray[i].Trim() + ";"
    	}
    } 
    var str = "";
    for (i = 0; i < idsArray.length; i++) 
    { 
    	str = str + idsArray[i].Trim();
    } 
    document.getElementById('receiver').value = idsString;
    document.body.removeChild(obj);
}  

function getoffset(e)   
{   
	var t=e.offsetTop;   
	var l=e.offsetLeft;   
	while(e=e.offsetParent)   
	{   
   		t+=e.offsetTop;   
   		l+=e.offsetLeft;   
	}   
	var rec = new Array(1);   
	rec[0] = t;   
	rec[1] = l;   
	return rec   
} 

效果如图:

技术分享

html 浮动窗口

标签:

原文地址:http://blog.csdn.net/coslay/article/details/44171985

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!