Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document.addEventListener Object doesn't support this property or method #13

Open
flip111 opened this issue Mar 6, 2014 · 0 comments
Open

Comments

@flip111
Copy link

flip111 commented Mar 6, 2014

Browser:
Internet Explorer 8.0.6001.19222

Error:
Object doesn't suppor this property or method javascript2_logout_6.js, line 20, character 1 (actual line does not match with error line because of removing commented lines from snippet)

test.html

<html>
  <head>
    <title>EventListener Test</title>
    <meta charset="UTF-8">
        <script src="/js/EventListener-42bbf89f83.min.js"></script>
        <script type="text/javascript">
            var logoutPath = '/app_dev.php/en/logout';
            var logoutTime = 1800000;
        </script>
        <script type="text/javascript" src="/app_dev.php/javascript2_logout_6.js"></script>
  </head>
  <body>

  </body>
</html>

/app_dev.php/javascript2_logout_6.js

var logoutTimeout, mouseListener, setLogoutTimer;

setLogoutTimer = function() {
    logoutTimeout = window.setTimeout(function() {
        window.location = logoutPath;
    }, logoutTime);
};

mouseListener = function () {
    window.clearTimeout(logoutTimeout);
    setLogoutTimer();
};

setLogoutTimer();
document.addEventListener('mousemove', mouseListener, false); // Errors here

/js/EventListener-42bbf89f83.min.js = https://raw.github.com/jonathantneal/EventListener/master/EventListener.js + http://javascript-minifier.com/

this.Element&&Element.prototype.attachEvent&&!Element.prototype.addEventListener&&function(){function e(e,t){Window.prototype[e]=HTMLDocument.prototype[e]=Element.prototype[e]=t}function t(){t.interval&&document.body&&(t.interval=clearInterval(t.interval),document.dispatchEvent(new CustomEvent("DOMContentLoaded")))}e("addEventListener",function(e,t){var n=this,r=n.addEventListener.listeners=n.addEventListener.listeners||{},a=r[e]=r[e]||[];a.length||n.attachEvent("on"+e,a.event=function(e){var t=n.document&&n.document.documentElement||n.documentElement||{scrollLeft:0,scrollTop:0};e.currentTarget=n,e.pageX=e.clientX+t.scrollLeft,e.pageY=e.clientY+t.scrollTop,e.preventDefault=function(){e.returnValue=!1},e.relatedTarget=e.fromElement||null,e.stopImmediatePropagation=function(){i=!1,e.cancelBubble=!0},e.stopPropagation=function(){e.cancelBubble=!0},e.target=e.srcElement||n,e.timeStamp=+new Date;for(var r,o=0,l=[].concat(a),i=!0;i&&(r=l[o]);++o)for(var c,s=0;c=a[s];++s)if(c==r){c.call(n,e);break}}),a.push(t)}),e("removeEventListener",function(e,t){for(var n,r=this,a=r.addEventListener.listeners=r.addEventListener.listeners||{},o=a[e]=a[e]||[],l=o.length-1;n=o[l];--l)if(n==t){o.splice(l,1);break}!o.length&&o.event&&r.detachEvent("on"+e,o.event)}),e("dispatchEvent",function(e){var t=this,n=e.type,r=t.addEventListener.listeners=t.addEventListener.listeners||{},a=r[n]=r[n]||[];try{return t.fireEvent("on"+n,e)}catch(o){return void(a.event&&a.event(e))}}),Object.defineProperty(Window.prototype,"CustomEvent",{get:function(){var e=this;return function(t,n){var r,a=e.document.createEventObject();a.type=t;for(r in n)"cancelable"==r?a.returnValue=!n.cancelable:"bubbles"==r?a.cancelBubble=!n.bubbles:"detail"==r&&(a.detail=n.detail);return a}}}),t.interval=setInterval(t,1),window.addEventListener("load",t)}(),!this.CustomEvent&&function(){window.CustomEvent=function(e,t){var n;t=t||{bubbles:!1,cancelable:!1,detail:void 0};try{n=document.createEvent("CustomEvent"),n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail)}catch(r){n=document.createEvent("Event"),n.initEvent(e,t.bubbles,t.cancelable),n.detail=t.detail}return n}}();

This script worked for me but has less features: https://gist.github.com/eirikbacker/2864711

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

No branches or pull requests

1 participant