I am redirecting my user to my default.aspx when his session expires and default page is referenced under a master page. I show a notification like twitter stating Session
I could not find the place where topBar
is called, but if I call it from $(document).ready()
it worked like a charm in my IE8:
<script type="text/javascript">
function topBar(message) {
$("#alertmsg").remove();
var $alertdiv = $('<div id = "alertmsg"/>');
$alertdiv.text(message);
$alertdiv.bind('click', function() {
$(this).slideUp(200);
});
$(document.body).append($alertdiv);
$("#alertmsg").slideDown("slow");
setTimeout(function() { $alertdiv.slideUp(200); }, 5000);
}
$(document).ready(function() {
topBar("Hello world!");
});
</script>
You could also use $(window).load()
if you have graphics and/or other heavy elements that needs to be loaded before topBar()
is called:
$(window).load(function() {
topBar("Hello world!");
});
Hope it helps.
EDIT:
Maybe this can be of some help? Basically you could do something like this:
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "json",
@"$(document).ready(function(){
topBar("Hello world!");
});
});", true);
Check out the answer in the link because he gives a couple of alternatives