Take the 2-minute tour ×

I use html5 history pushstate to load some blog post page.

Inside each loaded page via pushstate I have a slider (iosslider). When I load the blog page, the slider doesn't work. I think I need to callback the iosslider script.

Here is the iosslider script to initialize it:

responsiveSlideContainer: true,
responsiveSlides: true,
snapToChildren: true,
desktopClickDrag: true,
keyboardControls: true,
infiniteSlider: true,
navSlideSelector: true,
autoSlide: true,
autoSlideTimer: 5000,
navNextSelector: $('.slider-next'),
navPrevSelector: $('.slider-prev'),
navSlideSelector: $('.slider-pagination .slider-page'),
onSlideChange: slideChange

How can I initialize the script when I trigger pushstate?

Sorry for my English, I'm French.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You could use window.onpopstate event to call the script.

Check the doc there:



Did you try this:



And do you have any errors in the console?

Edit 2

I doubt it's related to sync/async. The thing is that the page is not really "reloaded" when you use pushstate. My guess it that the script of the slider just stopped, and you need to start it again, but it is already instanciated you cannot just initialize it again.

Try to:


and then initialize it again.

In your onpopstate function place it after this:

 if (event.state) {
        load_content(event.state.title, window.location.pathname, true);
        // here

Edit 3


$(window).load(function () { 
     // initialize

Be aware that onload will be triggered before onpopstate.

share|improve this answer
thank you but it don't work... –  freaky Jun 10 '13 at 14:59
Show me the sample of code where you try that. And it's "doesn't"* for the third person by the way ;) –  Maresh Jun 10 '13 at 15:04
And show the pushstate call as well. –  Maresh Jun 10 '13 at 15:07
You can see my pushstate script here : stackoverflow.com/questions/16658895/… , without any callback script. The best way is to callback inside my load_content function but it doesn't works. I think it's because the asynchronous task... –  freaky Jun 10 '13 at 15:08
Check my edits. –  Maresh Jun 10 '13 at 15:14
show 11 more comments

Your Answer


