博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
将网页以编辑框形式弹出方法2(Jquery 方法)
阅读量:5815 次
发布时间:2019-06-18

本文共 5839 字,大约阅读时间需要 19 分钟。

不做解释大家看看就明白了,下面是我项目的源代码。

tipswindows.js文件

///-------------------------------------------------------------------------//jQuery弹出窗口 By Await [2009-11-22]//--------------------------------------------------------------------------/*参数:[可选参数在调用时可写可不写,其他为必写]----------------------------------------------------------------------------    title:	窗口标题  content:  内容(可选内容为){ text | id | img | url | iframe }    width:	内容宽度   height:	内容高度	 drag:  是否可以拖动(ture为是,false为否)     time:	自动关闭等待的时间,为空是则不自动关闭   showbg:	[可选参数]设置是否显示遮罩层(0为不显示,1为显示)  cssName:  [可选参数]附加class名称 ------------------------------------------------------------------------*/ //示例: //------------------------------------------------------------------------ //simpleWindown("例子","text:例子","500","400","true","3000","0","exa") //------------------------------------------------------------------------var showWindown = true;var templateSrc = "http://leotheme.cn/wp-content/themes/Dreamy"; //设置loading.gif路径function tipsWindown(title,content,width,height,drag,time,showbg,cssName) {	$("#windown-box").remove(); //请除内容	var width = width>= 950?this.width=950:this.width=width;	    //设置最大窗口宽度	var height = height>= 527?this.height=527:this.height=height;  //设置最大窗口高度	if(showWindown == true) {		var simpleWindown_html = new String;			simpleWindown_html = "
"; simpleWindown_html += "
"; simpleWindown_html += "

关闭
"; simpleWindown_html += "
"; simpleWindown_html += "
"; $("body").append(simpleWindown_html); show = false; } contentType = content.substring(0,content.indexOf(":")); content = content.substring(content.indexOf(":")+1,content.length); switch(contentType) { case "text": $("#windown-content").html(content); break; case "id": $("#windown-content").html($("#"+content+"").html()); break; case "img": $("#windown-content").ajaxStart(function() { $(this).html(""); }); $.ajax({ error:function(){ $("#windown-content").html("

加载数据出错...

"); }, success:function(html){ $("#windown-content").html(""); } }); break; case "url": var content_array=content.split("?"); $("#windown-content").ajaxStart(function(){ $(this).html(""); }); $.ajax({ type:content_array[0], url:content_array[1], data:content_array[2], error:function(){ $("#windown-content").html("

加载数据出错...

"); }, success:function(html){ $("#windown-content").html(html); } }); break; case "iframe": $("#windown-content").ajaxStart(function(){ $(this).html(""); }); $.ajax({ error:function(){ $("#windown-content").html("

加载数据出错...

"); }, success:function(html){ $("#windown-content").html(""); } }); } //download by http://www.codefans.net $("#windown-title h2").html(title); if(showbg == "true") {$("#windownbg").show();}else {$("#windownbg").remove();}; $("#windownbg").animate({opacity:"0.5"},"normal");//设置透明度 $("#windown-box").show(); if( height >= 527 ) { $("#windown-title").css({width:(parseInt(width)+22)+"px"}); $("#windown-content").css({width:(parseInt(width)+17)+"px",height:height+"px"}); }else { $("#windown-title").css({width:(parseInt(width)+10)+"px"}); $("#windown-content").css({width:width+"px",height:height+"px"}); } var cw = document.documentElement.clientWidth,ch = document.documentElement.clientHeight,est = document.documentElement.scrollTop; var _version = $.browser.version; if ( _version == 6.0 ) { $("#windown-box").css({left:"50%",top:(parseInt((ch)/2)+est)+"px",marginTop: -((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"}); }else { $("#windown-box").css({left:"50%",top:"50%",marginTop:-((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"}); }; var Drag_ID = document.getElementById("windown-box"),DragHead = document.getElementById("windown-title"); var moveX = 0,moveY = 0,moveTop,moveLeft = 0,moveable = false; if ( _version == 6.0 ) { moveTop = est; }else { moveTop = 0; } var sw = Drag_ID.scrollWidth,sh = Drag_ID.scrollHeight; DragHead.onmouseover = function(e) { if(drag == "true"){DragHead.style.cursor = "move";}else{DragHead.style.cursor = "default";} }; DragHead.onmousedown = function(e) { if(drag == "true"){moveable = true;}else{moveable = false;} e = window.event?window.event:e; var ol = Drag_ID.offsetLeft, ot = Drag_ID.offsetTop-moveTop; moveX = e.clientX-ol; moveY = e.clientY-ot; document.onmousemove = function(e) { if (moveable) { e = window.event?window.event:e; var x = e.clientX - moveX; var y = e.clientY - moveY; if ( x > 0 &&( x + sw < cw) && y > 0 && (y + sh < ch) ) { Drag_ID.style.left = x + "px"; Drag_ID.style.top = parseInt(y+moveTop) + "px"; Drag_ID.style.margin = "auto"; } } } document.onmouseup = function () {moveable = false;}; Drag_ID.onselectstart = function(e){return false;} } $("#windown-content").attr("class","windown-"+cssName); var closeWindown = function() { $("#windownbg").remove(); $("#windown-box").fadeOut("slow",function(){$(this).remove();}); } if( time == "" || typeof(time) == "undefined") { $("#windown-close").click(function() { $("#windownbg").remove(); $("#windown-box").fadeOut("slow",function(){$(this).remove();}); }); }else { setTimeout(closeWindown,time); }}

 前台引用;

function TipEdit(id) {            if (id != null) {                tipsWindown("报名信息", "iframe:SignupDLAdd.aspx?type=edit&id=" + id, "880", "420", "true", "", "true");                //  tipsWindown("收费信息", "iframe:SignUpPrice.aspx?type=edit&id=" + id, "590", "260", "true", "", "true");            }            else {                tipsWindown("报名信息", "iframe:SignupDLAdd.aspx?type=new", "880", "420", "true", "", "true");            }        }......  

 

转载于:https://www.cnblogs.com/kainjie/p/3424805.html

你可能感兴趣的文章
Java并发框架——什么是AQS框架
查看>>
【数据库】
查看>>
Win配置Apache+mod_wsgi+django环境+域名
查看>>
第四届中国汽车产业信息化技术创新峰会将于6月在沪召开
查看>>
linux清除文件内容
查看>>
WindowManager.LayoutParams 详解
查看>>
find的命令的使用和文件名的后缀
查看>>
Android的Aidl安装方法
查看>>
Linux中rc的含义
查看>>
曾鸣:区块链的春天还没有到来| 阿里内部干货
查看>>
如何通过Dataworks禁止MaxCompute 子账号跨Project访问
查看>>
js之无缝滚动
查看>>
Django 多表联合查询
查看>>
logging模块学习:basicConfig配置文件
查看>>
Golang 使用 Beego 与 Mgo 开发的示例程序
查看>>
ntpdate时间同步
查看>>
+++++++子域授权与编译安装(一)
查看>>
asp.net怎样在URL中使用中文、空格、特殊字符
查看>>
ASA5585-S20测试方案
查看>>
路由器发布服务器
查看>>