简体   繁体   中英

How to show pop-up message dynamically

I create a popup based on this post
but i want to create it based on visitor

I use below code in index.aspx page:

<div id='message' style="display: none;">
    <span>Wellcome 
        <%=UserName%></span> <a href="#" class="close-notify" onclick="closeNotice()">X</a>
</div>

and I show pop-up using jquery :

<script type="text/javascript">

$(document).ready(function() {
    $("#message").fadeIn("slow");

});

function closeNotice() {
    $("#message").fadeOut("slow");
}
</script>

now i want show this pop up only when user enter OR when CheckBox1.Checked value in "editor.aspx" is true...but time pop-up display every time that page load(even if user don't log in )

Why not create a Javascript variable and set it's value on !IsPostBack.

<script type="text/javascript">

var postBack = <%=IsPostedBack%>// you can use a variable from codebehind

if(postBack == false) $("#message").fadeIn("slow");

$("#message").fadeOut("slow");

</script>

Inside Page_Load function set IsPostedBack.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM