jquery - javascript runtime error trying to display notification -


i found following code displays toast-style alerts in mobile web applications , want use show these messages users in mobile client:

var toast = function (msg) { $("<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h3>" + msg + "</h3></div>") .css({     display : "block",     opacity : 0.90,     position : "fixed",     padding : "7px",     text-align : "center",     width : "270px",     left : ($(window).width() - 284) / 2,     top : $(window).height() / 2 }) .appendto($.mobile.pagecontainer).delay(1500) .fadeout(400, function () {     $(this).remove(); }); } 

i call javascript this:

toast("this test message"); 

when navigate page code located, shows message fine first time. when go page (after visiting first time), error:

0x800a138f - javascript runtime error: unable property 'pagecontainer' of undefined or null reference

what causing error , how can resolve error? want function able execute no matter how many times page visited.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -