I have got a link with the click event in my JQuery, something like below:
$('#TopLoginLink').click(function()
{
//Here I want the current page should be reloaded with "https" and after the page is loaded then it will automatically call my function MyDialogPopup(). Something like 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 is reloading my page perfectly, however my problem is that my function is also called immediatley, but I want my function should be called only when my page is loaded with "https" completely.
Please suggest! how can I achieve this
You should define some flag. For example put something in cookies or append to url. Then, in your javascript define ready handler then will be called when page is loaded:
$(document).ready(function() {
if (checkFlag()){
MyDialogPopup();
clearFlag();
}
});
Your handler will be looking like this:
if (https!=' ')
{
reloadURL = myCurrentPage.replace('#','').replace("http",https);
setFlag();
window.location.href = reloadURL;
}
If your stick with cookies, you can use jquery.cookie plugin. Here is code for setFlag, checkFlag, clearFlag:
function setFlag(){
$.cookie('show_dlg', 'true');
}
function clearFlag(){
$.cookie('show_dlg', null);
}
function checkFlag(){
return $.cookie('show_dlg') == 'true';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With