mailto: anchor links unloading html5 video in Chrome

Posted by Robin Pyon on Stack Overflow See other posts from Stack Overflow or by Robin Pyon
Published on 2012-12-14T17:02:01Z Indexed on 2012/12/14 17:03 UTC
Read the original article Hit count: 155

I have a very simple page with a <video> tag and an email anchor link:
http://jsfiddle.net/6GquX/3/

Clicking the email link in Chrome (OS X 10.8 + Win7, 23.0.1271.97) invokes the beforeunloadchange event and causes the video to unload, which isn't the desired outcome.

Curiously enough, if I let the video buffer a bit and then click the email link, the video keeps playing and doesn't unload.

To my knowledge this only occurs in Chrome and I'm truly at a loss. Visiting any HTML5 video player site (videojs, flowplayer etc), starting a HTML5 video and then immediately simulating an email click with document.location.href = "mailto:[email protected]" in the dev console yields the same error.

However, I'm inclined to think it's the way in which the video has been encoded as I'm unable to recreate the above with a video downloaded from YouTube's HTML5 player:
http://jsfiddle.net/6GquX/4/ (source)

1. Is it possible that YouTube are encoding their videos in a particular way to combat this?
2. Are there any strategies / hacks I can employ to get around this?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html