如何在标题上创建弹出框,当点击关闭按钮时,不使用jquery或php在网站中显示

How to create popup box on header and when click on close button then not display in the site using jquery or php?

本文关键字:jquery 显示 网站 php 关闭按钮 创建 标题      更新时间:2023-09-26

我想使用jqueryPHPJavascript:创建功能

加载网站后,在标题上显示弹出框并关闭按钮,当点击关闭按钮时,弹出窗口关闭。如果未单击在关闭按钮上,则弹出窗口显示在网站

你能给我建议吗?我不知道。

类似fancybox的东西?U可以使用该CCD_ 5。

编辑

按照你给出的链接试试这个在你的php页面中放置这个。

<?php session_start();?>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
//jquery code
$(document).ready(function(){
$('#close_popup').click(function(){
$('#header').css('display','none');
$.post("test.php");
});
})
</script>
</head>
<body>
<div id="header" style="width:100%;top:0;<?php if(isset($_SESSION['isHeaderClosed']) && $_SESSION['isHeaderClosed'] == true) echo 'display:none;'; ?>">
content <input type="button" id="close_popup"/>
</div>
</body>
</html>

(在所有页面中放置session_start()、div标题和jquery代码)。

在新页面测试中.php

<?php
session_start();
$_SESSION['isHeaderClosed']=true;
?>

试试这个-DEMO

单击按钮时,我们将字段集的display属性设置为none,因此不显示。