PHP送信フォームのレイヤーポップアップiframeを閉じる方法を説明する例

coldplay.xixi
リリース: 2023-04-09 13:54:02
転載
3001 人が閲覧しました

PHP送信フォームのレイヤーポップアップiframeを閉じる方法を説明する例

非常に使いやすいフロントエンド ポップアップ プラグインの紹介:

layer 公式 Web サイトのアドレス: http://layer.layui.com/

公式 API によると: Layer の iframe ポップアップ ウィンドウ

//iframe层-父子操作
layer.open({ 
 type: 2, 
 area: ['700px', '530px'], 
 fix: false, //不固定 
 maxmin: true, 
 content: 'test/iframe.html'
});
ログイン後にコピー

こちらPHP 開発を例として、フォームの送信後にレイヤーのポップアップ ウィンドウを自動的に閉じる

(1) レイヤー編集ボックスをポップアップします:

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) ページのメイン コードを編集します

ログイン後にコピー

(3) PHP はバックグラウンドでデータを保存し、レイヤー ウィンドウを閉じるメソッドを指します

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){
				showmessage(L('operation_success'),'?m=content&c=meiti&a=closewindow');//保存成功指向关闭窗口方法
			}
		}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) ウィンドウを閉じて、親ウィンドウ ページのキー コードを更新します

$(function(){
 parent.location.reload();//刷新父窗口 
 parent.layer.closeAll();//关闭所有layer窗口
});
ログイン後にコピー

注: Thisページは、レイヤー メソッドを使用するためにレイヤーに必要な JS ライブラリをロードする必要があります。

関連学習の推奨事項:

phpprogramming(ビデオ)

以上がPHP送信フォームのレイヤーポップアップiframeを閉じる方法を説明する例の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

関連ラベル:
ソース:jb51.net
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!