jsforim

来源:互联网 发布:支付宝 java 服务器端 编辑:程序博客网 时间:2024/05/17 08:12

 

var isMouseDown=false;
var isFirst=true;
var centerdivObj;
var ndiv1;
var ndiv2;
var ndiv3;
var kjX;
var kjY;

window.onerror=function()
{
    return true;
};

var thurl='http://qq.jutoo.net/';
var wzId='12345';

function createDiv()

    var sW=screen.width;
    var sH=screen.height;
   
    createDivObj();
    //中间div
    centerdivObj.style.position="absolute";
    centerdivObj.id="cd_id";
    centerdivObj.style.left=(sW-439)/2+"px";
    centerdivObj.style.top=(sH-159-200)/2+"px";
    centerdivObj.style.width="439px";
    centerdivObj.style.height="159px";
    centerdivObj.style.overflow="hidden";
    centerdivObj.style.cursor="move";
    centerdivObj.style.backgroundImage="url("+thurl+"Image/tt.bmp)";
   
    document.body.appendChild(centerdivObj);
    //左边div
    var leftDivObj=document.createElement("div")
    leftDivObj.style.position="absolute";
    leftDivObj.style.left="10px";
    leftDivObj.style.top="50px";
    leftDivObj.style.visibility="visible";
    document.body.appendChild(leftDivObj);
   
    //左边小div头部
    var leftDivMinObj=document.createElement("div")
    leftDivMinObj.style.position="absolute";
    leftDivMinObj.style.cursor="pointer";
    leftDivMinObj.style.left="10px";
    leftDivMinObj.style.top="50px";
    leftDivMinObj.style.width="117px";
    leftDivMinObj.style.height="20px";
    leftDivMinObj.style.backgroundImage="url("+thurl+"Image/leftt.gif)";
    leftDivMinObj.style.visibility="hidden";
    leftDivMinObj.onclick=function()
    {
        leftDivObj.style.visibility="visible";
        leftDivMinObj.style.visibility="hidden";
    };
    document.body.appendChild(leftDivMinObj);
   
    //左边div头部
    var leftDivHeadObj=document.createElement("div");
    leftDivHeadObj.style.cursor="pointer";
    leftDivHeadObj.style.width="117px";
    leftDivHeadObj.style.height="20px";
    leftDivHeadObj.style.backgroundImage="url("+thurl+"Image/leftt.gif)";
    leftDivHeadObj.onclick=function()
    {
        leftDivObj.style.visibility="hidden";
        leftDivMinObj.style.visibility="visible";
    };
    leftDivObj.appendChild(leftDivHeadObj);
   
    //左边div中间部
    var leftDivbodyObj=document.createElement("div");
    if(document.compatMode=="CSS1Compat")
        leftDivbodyObj.style.width="111px";
    else if(document.compatMode=="BackCompat")
        leftDivbodyObj.style.width="117px";   //不要指定高,指定了高div就不会延伸了(兼容问题)
    leftDivbodyObj.style.overflowX="hidden";
    leftDivbodyObj.style.border="rgb(0,100,191) solid 3px";
    leftDivbodyObj.style.borderTop="none";
    leftDivbodyObj.style.borderBottom="none";
    leftDivbodyObj.style.backgroundColor="white";
    leftDivbodyObj.style.fontSize="10pt";
    leftDivbodyObj.style.paddingTop="5px";
    leftDivbodyObj.innerHTML="<img src='http://qq.jutoo.net/Image/kzx.bmp' width='111px' height='16px'/><br><img src='http://qq.jutoo.net/Image/klx.bmp' width='111px' height='16px'/><br><a href='#' style='text-decoration:none;color:black' onclick="+"javascript:window.open(encodeURI('http://qq.jutoo.net/LeaveWord.aspx?wzid=12345&bumen=在线客服'),'','width=650px,height=455px,resizable=yes')"+"><img src='http://qq.jutoo.net/Image/offline.ico' border='0' width='10px' height='10px' style='margin:8px 0 8px 0' align='absmiddle'>在线客服<img src='http://qq.jutoo.net/Image/offline.gif' border='0'></a><br><a href='#' style='text-decoration:none;color:black' onclick="+"javascript:window.open(encodeURI('http://qq.jutoo.net/LeaveWord.aspx?wzid=12345&bumen=技术部'),'','width=650px,height=455px,resizable=yes')"+"><img src='http://qq.jutoo.net/Image/offline.ico' border='0' width='10px' height='10px' style='margin:8px 0 8px 0' align='absmiddle'>技术部<img src='http://qq.jutoo.net/Image/offline.gif' border='0'></a><br>";//
    leftDivObj.appendChild(leftDivbodyObj);
   
    //左边div低部
    var leftDivfootObj=document.createElement("div");
    leftDivfootObj.style.width="117px";
    leftDivfootObj.style.height="11px";
    leftDivfootObj.style.overflow="hidden";
    leftDivfootObj.style.backgroundImage="url("+thurl+"Image/leftd.gif)";
   
    leftDivObj.appendChild(leftDivfootObj);
    //2个按钮外层的div
    ndiv1=document.createElement("div");
    ndiv1.style.position="absolute";
    ndiv1.style.left="120px";
    ndiv1.style.top="120px";
    ndiv1.style.width="300px";
    ndiv1.style.height="30px";
    ndiv1.style.cursor="pointer";
    ndiv1.align="center";
   
    centerdivObj.appendChild(ndiv1);
   
    ndiv1.innerHTML="<a href='#' onclick="+"javascript:document.getElementById('cd_id').style.visibility='hidden';window.open(encodeURI('http://qq.jutoo.net/LeaveWord.aspx?wzid=12345&bumen=在线客服'),'','width=650px,height=455px,resizable=yes')"+"><img src='http://qq.jutoo.net/Image/ly.bmp' border='0'></a>&nbsp;";
   
    var xxbutton=document.createElement("input");
    xxbutton.type="image";
    xxbutton.src=thurl+"Image/xx.bmp";
    xxbutton.onclick=function()
    {
        centerdivObj.style.visibility="hidden";
        window.open(encodeURI(thurl + "HandSetNote.aspx?wzid=" + wzId),"","width=650px,height=455px,resizable=yes");
    };
   
    ndiv1.appendChild(xxbutton);
   
    var kgtext=document.createTextNode(" ");
   
    ndiv1.appendChild(kgtext);
   
    var callbutton=document.createElement("input");
    callbutton.type="image";
    callbutton.src=thurl+"Image/dh.bmp";
    callbutton.onclick=function()
    {
        centerdivObj.style.visibility="hidden";
        window.open(encodeURI(thurl + "TelCall.aspx?wzid=" + wzId),"","width=650px,height=455px,resizable=yes");
    };
   
    ndiv1.appendChild(callbutton);
   
    ndiv2=document.createElement("div");
    ndiv2.style.position="absolute";
    ndiv2.style.left="140px";
    ndiv2.style.top="50px";
    ndiv2.style.width="260px";
    ndiv2.style.height="60px";
    ndiv2.innerHTML="<font style='font-size:10pt'>欢迎您光临!请您给 在线客服 留言。</font>";
   
    centerdivObj.appendChild(ndiv2);
   
    ndiv3=document.createElement("div");
    ndiv3.style.position="absolute";
    ndiv3.style.left="420px";
    ndiv3.style.top="5px";
    ndiv3.style.width="20px";
    ndiv3.style.height="20px";
    ndiv3.innerHTML="<font color='white'>X</font>";
    ndiv3.style.cursor="pointer";
    ndiv3.onclick=function()
    {
        centerdivObj.style.visibility="hidden";
    };
    centerdivObj.appendChild(ndiv3);
   
    //div的滚动
    var divtop=centerdivObj.style.top.replace("px","")-0;
    var thdivtop=leftDivObj.style.top.replace("px","")-0;
    var leftmintop=leftDivMinObj.style.top.replace("px","")-0;
   
    window.onscroll=function()
    {
        if(document.compatMode=="CSS1Compat")
        {
            centerdivObj.style.top=document.documentElement.scrollTop+divtop+"px";  //有 dtd 用这个
            leftDivObj.style.top=document.documentElement.scrollTop+thdivtop+"px";
            leftDivMinObj.style.top=document.documentElement.scrollTop+leftmintop+"px";
        }   
        else if(document.compatMode=="BackCompat")
        {
            centerdivObj.style.top=document.body.scrollTop+divtop+"px";   //没有 dtd 用这个
            leftDivObj.style.top=document.body.scrollTop+thdivtop+"px";
            leftDivMinObj.style.top=document.body.scrollTop+leftmintop+"px"
        }
    };
   
    centerdivObj.onmousedown=divMouseDown;
    centerdivObj.onmousemove=function(){divMouseMove(getWindowEvent(getWindowEvent))};
    centerdivObj.onmouseup=divMouseUp;
}

function divMouseDown()
{
    isMouseDown=true;
}

function divMouseMove(e)
{
    if(isMouseDown)
    {
        if(window.navigator.appName.toLowerCase()=="microsoft internet explorer")
            centerdivObj.setCapture();
       
        var mouseX=e.clientX;
        var mouseY=e.clientY;

        var divLeft=centerdivObj.style.left.replace("px","")-0;
        var divTop=centerdivObj.style.top.replace("px","")-0;
       
        if(isFirst)  //第一次取
        {
            kjX=mouseX-divLeft;
            kjY=mouseY-divTop;
           
            isFirst=false;
        }

        centerdivObj.style.left=mouseX-kjX+"px";
        centerdivObj.style.top=mouseY-kjY+"px"
    }
}

function divMouseUp()
{
    isMouseDown=false;
    isFirst=true;
   
    if(window.navigator.appName.toLowerCase()=="microsoft internet explorer")
        centerdivObj.releaseCapture();
}

function createDivObj()
{
    centerdivObj=document.createElement("div");
}

createDiv();

function getWindowEvent(methodName)
{
    if(document.all)
        return window.event;
    else
        return methodName.caller.arguments[0];
}

原创粉丝点击