##Introducing a very easy-to-use front-end pop-up plug-in:
layer official website address: http://layer.layui.com/According to the official API: layer’s iframe pop-up window//iframe层-父子操作 layer.open({ type: 2, area: ['700px', '530px'], fix: false, //不固定 maxmin: true, content: 'test/iframe.html' });
(1) Pop up the layer editing box:
function edit(id){ if(id==null||id==''||id=='undefined'){ alert('操作编号为空,请联系管理员'); } layer.open({ type: 2, area: ['700px', '530px'], fix: false, //不固定 maxmin: true, content: 'index.php?m=content&c=meiti&a=edit_paiqi&id='+id }); }
(2) Edit the main code of the page
<input name="dosubmit" type="submit" id="dosubmit" value="提交" class="button" >
(3) PHP saves data in the background and points to a method to close the layer window
public function edit_config_paiqi(){ $id = trim($_REQUEST['id']); $paiqi_db = pc_base::load_model('paiqi_config_model'); if($_REQUEST['dosubmit']){ $insertinfo = array(); $insertinfo['catid'] = trim($_POST['catid']); $insertinfo['meitiid'] = trim($_POST['meitiid']); $insertinfo['title'] = trim($_POST['title']); $insertinfo['meitizhuname'] = trim($_POST['meitizhuname']); $insertinfo['meitizhuid'] = trim($_POST['meitizhuid']); $insertinfo['createtime'] = SYS_TIME; $insertinfo['saturation'] = trim($_POST['saturation']); $datas = $paiqi_db->update($insertinfo,array("id"=>$id)); if($datas){ <span style="color:#ff0000;">showmessage(L('operation_success'),'?m=content&c=meiti&a=closewindow');//保存成功指向关闭窗口方法</span> } }else{ $datas = $paiqi_db->select(array("id"=>$id)); $template = "edit_config_paiqi"; include $this->admin_tpl($template); } }
/** * 关闭layer层 */ public function closewindow(){ $template = "close_layer"; include $this->admin_tpl($template); }
(4) Close the window and refresh the key code of the parent window page
$(function(){ parent.location.reload();//刷新父窗口 parent.layer.closeAll();//关闭所有layer窗口 });
Note: This page needs to load the js library required by the layer to use the layer method
Related learning recommendations:phpprogramming(video)
The above is the detailed content of Example to explain how to close layer pop-up iframe in php submission form. For more information, please follow other related articles on the PHP Chinese website!