开发者

Update successful notice with pure css and a close button

开发者 https://www.devze.com 2022-12-30 03:00 出处:网络
i\'ve seen websites that allow you to say update your profile and when the stuff is done, they\'ll stay in the same page or redirect you to another and with a fancy notice that says \"Update successfu

i've seen websites that allow you to say update your profile and when the stuff is done, they'll stay in the same page or redirect you to another and with a fancy notice that says "Update successful. click here to close" with a lowered opacity black background and a box in the middle with the text within.

I've got most of the stuff, the lowred opacity black background, the middle box with the text and even the click here to close function.

But how i did the "Click here to close" function is by using a link.

Let's say after updating the profile, my script redirect me to index.php?update=successful then i use

$update = $_GET['update'];
if ($update == "successful") {
echo    '<div id="BlackScreen"><p id="MiddleBox">You\'ve successfully update your
status!<br><span class="close"><a class="menu" href="index.php">Click to close.
</a></span></div></div>';
}
开发者_开发技巧

so that the lowered opacity background div will be gone, but is there another way to do this? Any tips please?


If javascript is an option (seems it might be from your comments), the jQuery example would be:

<script type="text/javascript">
$(function() {
  $("#BlackScreen a.menu").click(function() {
    $("#BlackScree").fadeOut();
  });
});
</script>


If you want to remove the message when the user clicks a button or link, you'll need to use Javascript. In the simplest form, you could do this:

echo  '<div id="BlackScreen"><p id="MiddleBox">'
    . 'You\'ve successfully update your status!<br>'
    . '<span class="close">'
    . '<a '
    .   'onclick="document.getElementById(\'BlackScreen\').style.display=\'none\'; return false" '
    .   'class="menu" href="index.php">Click to close.'
    . '</a></span></div></div>';

It's not a great solution, but it's an example of how easy it could be.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号