⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 priceshow.js

📁 本系统实现了从五个网站上搜索的图书进行整合后
💻 JS
字号:
function openDiv(_parent, iId){  
    
    if(!document.getElementById("msgTxt"))//判断是否有一个图层存在,防止多个同样的图层被打开
     {
        
         
         var $ = function(){
                return document.getElementById(arguments[0]) || false;
            }
             function getAbsPoint(e){
                 var x = e.offsetLeft, y = e.offsetTop;
                 while (e = e.offsetParent) {
                    x += e.offsetLeft;
                    y += e.offsetTop;
                 }
                 return {
                    x: x,
                    y: y
                 };
            }
              
                var parent = $(_parent);
                var newDiv = document.createElement("div");
                newDiv.id = "aaa";
                newDiv.style.position = "absolute";
                newDiv.style.zIndex = "9999";
                newDiv.style.width = "460px";
                newDiv.style.height = "230px";
                newDiv.style.background = "url(../images/floatdiv.gif)";  
                newDiv.style.top = (getAbsPoint(parent).y + parent.offsetHeight) + "px";//设置图层的相对位置
                newDiv.style.left = (getAbsPoint(parent).x+25) + "px"; 
                var title=document.createElement("h4");//创建一个h4对象(提示框标题栏)
                title.setAttribute("id","msgTitle");
                title.setAttribute("align","right");
                title.style.margin="0";
                title.style.padding="3px";
                title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
                title.style.opacity="0.75";
                title.style.height="18px";
                title.style.font="14px Verdana, Geneva, Arial, Helvetica, sans-serif";
                title.style.color="blue";//字体颜色
                title.style.cursor="pointer";
                title.innerHTML="<br>关闭&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                title.onclick=removeObj;
                               
                function removeObj(){//点击标题栏触发的事件
           
                        document.getElementById("aaa").removeChild(title);//删除提示框的标题栏
                        document.body.removeChild(newDiv);//删除提示框层
                }
                document.body.appendChild(newDiv);//在body内添加提示框div对象msgObj
                document.getElementById("aaa").appendChild(title);//在提示框div中添加标题栏对象title
                
                var txt=document.createElement("p");//创建一个p对象(提示框提示信息)
                //定义p的属性,即相当
                txt.style.position = "absolute";
                txt.style.width = "372px";
                txt.style.height = "220px";
                txt.style.top="12";
                txt.style.left="80";
                txt.style.font="14px Verdana, Geneva, Arial, Helvetica, sans-serif";
                txt.style.margin="1em 0"
                txt.setAttribute("id","msgTxt");
                txt.style.overflow = "scroll"; //添加滚动条
                txt.innerHTML="<br>正在加载中......";
                
                var xmlhttp;
	            try{
		                xmlhttp = new XMLHttpRequest();
	            }
	            catch(e){
		                 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	            }	
	
	            xmlhttp.onreadystatechange = function(){
		              if(xmlhttp.readyState == 4){
			             if(xmlhttp.status == 200){
                             txt.innerHTML=xmlhttp.responseText;//获取从后台返回的数据并把返回的数据加载到图层对象里显示
			             }
		               }
	            }
	            xmlhttp.open("POST","priceShow.do?id="+iId,true);
	            xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	            xmlhttp.send(""); 
              document.getElementById("aaa").appendChild(txt);//在提示框div中添加提示信息对象txt       
          }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -