Calling a Jquery function after the pages is loaded -
i have got link click event in jquery, below:
$('#toploginlink').click(function() { //here want current page should reloaded "https" , after page loaded automatically call function mydialogpopup(). below: var mycurrentpage = window.location.href.replace('#',''); var reloadurl; if (https!=' ') { reloadurl = mycurrentpage.replace('#','').replace("http",https); window.location.href = reloadurl; mydialogpopup(); } });
the above code reloading page perfectly, problem function called immediatley, want function should called when page loaded "https" completely.
please suggest! how can achieve this
you should define flag. example put in cookies or append url. then, in javascript define ready
handler called when page loaded:
$(document).ready(function() { if (checkflag()){ mydialogpopup(); clearflag(); } });
your handler looking this:
if (https!=' ') { reloadurl = mycurrentpage.replace('#','').replace("http",https); setflag(); window.location.href = reloadurl; }
if stick cookies, can use jquery.cookie plugin. here code setflag
, checkflag
, clearflag
:
function setflag(){ $.cookie('show_dlg', 'true'); } function clearflag(){ $.cookie('show_dlg', null); } function checkflag(){ return $.cookie('show_dlg') == 'true'; }
Comments
Post a Comment