zoukankan      html  css  js  c++  java
  • 遮罩层,可拖动

    效果:

    /*
    title: 窗口标题
    content: 内容(可选内容为){ text | id | img | url | iframe }
     内容宽度
    height: 内容高度
    drag: 是否可以拖动(ture为是,false为否)
    原理:主要是对div的z-index的控制。
    */
    $(document).ready(function(){
    	function TipsWindown(title,content,width,height,drag) {
    		$("#windown-box").remove(); 
    		this.title = title;
    		this.content = content;
    		this.width = width >= 950 ? this.width=950 : this.width = width;	    
    		this.height = height >= 527 ? this.height=527 : this.height= height; 
    		this.drag = drag?drag:true;
    		var that = this;
    		var windownBg_html = new String;
    		windownBg_html = "<div>"+
    						"<div id='windownbg' style='height:"+$(window).height()+"px;filter:alpha(opacity=0);opacity:0;z-index: 999900'></div>"+
    						"<div id='windown-box' class='ui-widget-content'>"+
    							"<div id='windown-title'><h2></h2><span id='windown-close'>关闭</span></div>"+
    							"<div id='windown-content-border'><div id='windown-content'></div></div>"
    						"</div>"+
    					"</div>";
    		var $template = $(windownBg_html);					
    		$template.find("h2").html(this.title);
    		$template.find("#windown-content").html($("#"+this.content).html());		
    		$("body").append($template.html());
    		$("#windownbg").show();
    		$("#windownbg").animate({opacity:"0.5"},"normal");
    		$("#windown-box").show();
    		if( this.height >= 527 ) {
    			$("#windown-title").css({(parseInt(this.width)+22)+"px"});
    			$("#windown-content").css({(parseInt(this.width)+17)+"px",height:this.height+"px"});
    		}else {
    			$("#windown-title").css({(parseInt(this.width)+10)+"px"});
    			$("#windown-content").css({width+"px",height:this.height+"px"});
    		}
    		$("#windown-box").css({left:"50%",top:"50%",marginTop:-((parseInt(this.height)+53)/2)+"px",marginLeft:-((parseInt(this.width)+32)/2)+"px"});
    		if(this.drag){
    			$("#windown-box").draggable();
    		}
    		$("#windown-close").live("click",function(){
    			that.closeWindown();
    		});
    }
    	TipsWindown.prototype.closeWindown = function(){
    		$("#windownbg").remove();
    		$("#windown-box").fadeOut("slow",function(){$(this).remove();});
    	}
    	var tipsWindownObject = null;
    	$("#isread").bind("click",function(){
    		tipsWindownObject = new TipsWindown("jquery弹出层", 'simTestContent', 600, 255);
    	});
    	$("#confirmTerm").live("click",function(){
    		tipsWindownObject.closeWindown();
    	});
    });
    

    下载地址:https://files.cnblogs.com/qduanlu/Float.zip

  • 相关阅读:
    使用tidylib解决不规则网页问题
    Python读取Json字典写入Excel表格的方法
    Python version 3.6 required, which was not found in the registry错误解决
    pip错误-failed to create process/fatal error in launcher
    Scrapy安装
    mongo数据库导入导出数据
    Windows命令
    Requests中文乱码解决方案
    mysql 1005 错误
    OC 内存管理-02 ARC 内存管理
  • 原文地址:https://www.cnblogs.com/qduanlu/p/2872770.html
Copyright © 2011-2022 走看看