I'm using the javascript code below to simulate a click on an iframe in Salesforce and hosted on my domain. I just want to simulate the first click on the iframe that's why i remove the event listner right after the iframe is clicked. But removing the event listner doesn't work. This function is called each the user click on the iframe. Do you know how i could achieve this ?

Thank you,

rerender : function( component, helper ) {



            setTimeout(function(){component.find('input').focus()}, 10);

            var onBlurHandler = function(event) {

                setTimeout($A.getCallback(function() {


                        if(document.activeElement == document


                removeEventListener('blur', onBlurHandler);

            addEventListener("blur", onBlurHandler);

This HTML DOM removeEventListener() Method documentation says:

To remove event handlers, the function specified with the addEventListener() method must be an external function, like in the example above (myFunction).

Anonymous functions, like "element.removeEventListener("event", function(){ myScript });" will not work.

Not entirely clear what an "external function" is...

You could side-step the problem by leaving the handler in place but make it do nothing after the first invocation:

        var active = true;
        var onBlurHandler = function(event) {
            if (active) {
            active = false;
        addEventListener("blur", onBlurHandler);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.