Skip to content
Browse files

use proper event Listener

  • Loading branch information...
1 parent 64e9601 commit 729f33d26450410ca69d252c63b83779e23e86ab @eduardocereto committed Dec 14, 2011
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/vimeo.js
View
15 src/vimeo.js
@@ -102,7 +102,18 @@ function _trackVimeo(force) {
}
}
if (vimeo_videos > 0 && _has_vimeo_window_event === false) {
- this._addEventListener(window, 'message', function(event) {
+ var WindowEvent = function(callback){
+ if (window.addEventListener) {
+ window.addEventListener('message', callback, false);
+ }
+ // IE
+ else {
+ window.attachEvent('onmessage', callback, false);
+ }
+ };
+
+
+ WindowEvent(function(event) {
if (sindexOf.call(event.origin, '//player.vimeo.com') > -1) {
var data = JSON.parse(event.data);
if (data.event === 'ready') {
@@ -117,7 +128,7 @@ function _trackVimeo(force) {
}
}
- }, false);
+ });
_has_vimeo_window_event = true;
}
}

0 comments on commit 729f33d

Please sign in to comment.
Something went wrong with that request. Please try again.