Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript not executed after clicking back button on IOS5 #30

Closed
tuupola opened this issue Mar 8, 2012 · 4 comments
Closed

JavaScript not executed after clicking back button on IOS5 #30

tuupola opened this issue Mar 8, 2012 · 4 comments
Assignees
Labels
Milestone

Comments

@tuupola
Copy link
Owner

tuupola commented Mar 8, 2012

Not directly related to Lazy Load. On IOS5 mobile Safari JavaScript is not executed when user clicks back button. Thus when user navigates away from page and comes back using back button images which have not been loaded yet will not be loaded even after scrolling.

Dirty workaround is to call window.onpopstate handler twice. First call happens on initial pageload. It will bind the second call to make all images appear. Second call happens when user clicks back button.

window.onpopstate = function() { 
    window.onpopstate = function() {
        $("img.lazy").trigger("appear");
    };
};

This is not optimal but works until real solution can be found. Another option seems to be something like (untested code):

if ((/iphone|ipod|ipad.*os 5/gi).test(navigator.appVersion)) {
    window.onpageshow = function(event) {
        if (event.persisted) {
            $("img.lazy").trigger("appear");
        };
    };
}
@ghost ghost assigned tuupola Mar 8, 2012
@risto1913
Copy link

Has there come any other solution to this issue?

@huangzj
Copy link

huangzj commented Aug 24, 2012

Looks like the issue is solved with iOS 6. Have tested the script on beta 4 and it's running as it should be without the solution about.

@tuupola
Copy link
Owner Author

tuupola commented Aug 24, 2012

I probably need to sniff if user has iOS 5 and include the workaround. Thanks for the info!

@tuupola
Copy link
Owner Author

tuupola commented Nov 10, 2012

Fixed in 1.8.2.

@tuupola tuupola closed this as completed Nov 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants