Skip to content
This repository has been archived by the owner on Apr 30, 2018. It is now read-only.

Allow Vimeo iframes after page load #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

williamjulianvicary
Copy link

Tweaks to the script to allow the tracking of Vimeo players that have
loaded after page load (i.e. via Ajax). Also a few bug fixes to ignore
iframes unrelated to vimeo.

Tweaks to the script to allow the tracking of Vimeo players that have
loaded after page load (i.e. via Ajax). Also a few bug fixes to ignore
iframes unrelated to vimeo.
@sanderheilbron
Copy link
Owner

@williamvicary Could you specify what HTML code is required to be modified. The following error shows up (with or without additional iframes from other domains) in the console:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://player.vimeo.com') does not match the recipient window's origin

I haven't checked for videos which are loaded after page load. Could you provide a demo?

You also removed checks for both the 'progress' and 'seek' data attributes which means you are breaking some functionality.

It also would be nice, when you send a pull request, you also include some modified documentation for users.

@williamjulianvicary
Copy link
Author

Whilst I did change some checks for data attributes I couldn't unpick what this code was actually doing? It seemed to be checking the attributes of the iframe but this data was also exposed using the callback from Vimeo so seemed like it was blocking functionality (ie seek/progress tracking didn't function without the attributes added to the iframes) - as issue #22 mentioned.

No HTML should need to be changed, as long as the iframe has the same ID as the player_id sent through to Vimeo and api=1 is sent it should work as normal (are you testing this on a localhost, thats the only reason I could think the origin wouldn't be working).

To check for videos after page load inject the code into the dom using Chrome inspect element or similar, adding something like this:

<iframe id="xyz" src="//player.vimeo.com/12345?api=1&player_id=xyz"></iframe>

That works the same as using Ajax to inject the code.

Apologies regarding the documentation, I also didn't minify the code (I didn't have that functionality), I was changing this for a client and figured pushing the changes I made to make it work would help.

Happy to test any problems you have though, not sure on pull etiquette (this is my first) so if you'd like to see any changes let me know!

@hallmatt
Copy link

I'm still receiving this issue. See the thumbnail below.

image

Here's the code I'm using:

<iframe src="//player.vimeo.com/video/109229310?api=1&player_id=109229310" id="109229310" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>

@BB-000
Copy link

BB-000 commented Jun 15, 2016

This would be great! Unfortunately I also get a postMessage error :( after loading in an iframe )

VM13764:5 Uncaught SyntaxError: Failed to execute 'postMessage' on 'Window': Invalid target origin '' in a call to 'postMessage'.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants