var iframe = function(){ var modalId = genID(10); /** * 页面load */ var build = function($title,$url,$param) { $width = $param.hasOwnProperty("width") ? $param['width'] : "100%"; $height = $param.hasOwnProperty("height") ? $param['height'] : "600px"; $footer = $param.hasOwnProperty("footer") ? $param['footer'] : 'block'; jQuery('body').prepend( '' ); $('#'+modalId).on('hide.bs.modal', function () { $('#'+modalId).remove(); }); }; $(document).on('click', '.modal-fullscreen-btn', function(){ $(this).closest('.modal-dialog').toggleClass('modal-fullscreen'); }); var open = function ($title,$url,$param={}) { build($title,$url,$param); $('#'+modalId).modal("show"); }; var close = function () { $('#'+modalId).modal("hide"); }; //生成随机ID避免id冲突 function genID(length){ return Number(Math.random().toString().substr(3,length) + Date.now()).toString(36); } return { // 页面加载动画 createIframe : function ($title,$url,$param={}) { open($title,$url,$param); } }; }();