用easyui动态创建一个对话框

function randomString(len) {
  len = len || 32;
  var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
  var maxPos = $chars.length;
  var pwd = '';
  for (i = 0; i < len; i++) {
    pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
  }
  return pwd;
}

function CreatSaveDialog(title,url,Dialog_w,Dialog_h){
 
 var div_id=randomString(5);
 var iframe_id=randomString(6);
 if (Dialog_w==null){
   Dialog_w=500;
 }else{
    if (Dialog_w>=$(window).width()){
     Dialog_w=$(window).width()-50;
     } 
 };
 if (Dialog_h==null){
   Dialog_h=300;
 }else{
    if (Dialog_h>=$(window).height()){
     Dialog_h=$(window).height()-50;
     } 
 };
 
 
 var htmlcontent='<div id=\"'+div_id+'\" class=\"easyui-dialog\" closed=\"true\" style=\"width:'+Dialog_w+'px;height:'+Dialog_h+'px;padding:10px;\">';
 htmlcontent=htmlcontent+'<iframe scrolling=\"no\" id=\"'+iframe_id+'\" frameborder=\"0\"  src=\"'+url+'\" style=\"width:100%;height:99%;\"></iframe>';
 htmlcontent=htmlcontent+'</div>';
 $(document.body).append(htmlcontent);
 div_id='#'+div_id;
 //$.parser.parse($(div_id).parent()); 这一句是直接生成。
 $(div_id).dialog({
                closed : false,
                title : title,
                shadow : true,
                modal : true,
    cache : false,
            });
 
 }

上一篇:读者汇app项目案例源码


下一篇:【读书笔记】【深入理解ES6】#13-用模块封装代码