changing vimeo embed's iframe src adds to history API

346 views Asked by At

I have a vimeo embed on my page. I'd like to change it to a different video when the user clicks a button. I do this by changing the "src" attribute in the iframe (example here):

$('.vimeoIFrame').attr('src','//player.vimeo.com/video/56534375');
  });

but weirdly, some new value gets pushed to the browser's history. How can I avoid this side-effect?

1

There are 1 answers

0
Huseyin Kuscu On BEST ANSWER

I got exactly the same problem around a year after yourself. Some code in embed player is pushing new values to the history as you update the src attribute and there's no workaround using the official api. This messes up my project which relies on the history.js for navigation.

SOLUTION: Just remove and create a new iframe element when you need to change your video. Vimeo player resets and do not need to push values to reach the previous videos.