Referenceerror: Event Is Not Defined Error in Firefox

ReferenceError: event is not defined error in Firefox

You're declaring (some of) your event handlers incorrectly:

$('.menuOption').click(function( event ){ // <---- "event" parameter here

event.preventDefault();
var categories = $(this).attr('rel');
$('.pages').hide();
$(categories).fadeIn();


});

You need "event" to be a parameter to the handlers. WebKit follows IE's old behavior of using a global symbol for "event", but Firefox doesn't. When you're using jQuery, that library normalizes the behavior and ensures that your event handlers are passed the event parameter.

edit — to clarify: you have to provide some parameter name; using event makes it clear what you intend, but you can call it e or cupcake or anything else.

Note also that the reason you probably should use the parameter passed in from jQuery instead of the "native" one (in Chrome and IE and Safari) is that that one (the parameter) is a jQuery wrapper around the native event object. The wrapper is what normalizes the event behavior across browsers. If you use the global version, you don't get that.

ReferenceError: event is not defined - Firefox

Not sure if it worked in Firefox because I don't want to use Firefox.

<!DOCTYPE html> <html>  <head>    <title>Test A</title>    <script>      function showCoords(evt){        alert(          "clientX value: " + evt.clientX + "\n" +          "clientY value: " + evt.clientY// + "\n"        );     }      function begin(){        parag = document.getElementById("parag");        parag.addEventListener("click", function(e) {showCoords(e);}, false);      }    </script>  </head>  <body onload="begin()">    <p id="parag">To display the mouse coordinates click in this paragraph.</p>  </body></html>

Firefox: ReferenceError: event is not defined

add event to function argument

$(".vma_overlay").click(function (event) {

var $videoSrcOriginal = $(event.target).

Firefox error: Event is not defined despite passing event as function argument

Use this code instead , firxfox expects a function with the event passed to it as a parmater but in your code the returned function from calling myfun()
doesn't have a parameter called event so it will return undefined use this example

$('#div, #link').click(myfunc());
function myfunc(){
return function(event){ if(event) { event.preventDefault(); } $('#result').show(); } }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div id="div">Div</div><a id="link" href="#">Link</a><div id="result" style="display:none">Clicked</div>

ReferenceError: event is not defined in mozila firefox

Use

<input type="text" id="txt1" class="search-bar-input" onkeyup="handleKeyPress(event, 'btn1');">

Then

function handleKeyPress(event) {
event = event || window.event //For IE
if (event.keyCode === 13) {
alert(event.keyCode);
}
}

Demo: Fiddle

Modal cannot be closed, Firefox says ReferenceError: event is not defined

I looked at your Plunker.

The error is self explaining: event is being used before it has been defined, that's why you get the ReferenceError, because the scope manager is getting mad.

Your dismissModal method calls bindEvents passing two parameters, the second one seems a callback.

This is confirmed by looking at your Plunker at the definition of bindEvents, which is:

function bindEvents(el, callback) {
for (i = 0; i < el.length; i++) {
if (window.CP.shouldStopExecution(0)) break;
(function(i) {
el[i].addEventListener('click', function(event) {
callback(this, event);
});
})(i);
}
window.CP.exitedLoop(0);
}

As you can see, the second parameter is a callback.
That callback gets called when click is made on a certain element, and it gets called with two parameters here:

callback(this, event);

Getting back to your code, then, we can see that event should be the second parameter of your callback:

function dismissModal() {
bindEvents(_dismiss, function(that, event) {
hideModal(event);
});
}

This way, it is defined (as the callback argument) and assigned by the bindEvents when an element is clicked.

Hope it is clear.

AngularJS - Firefox error - event is not defined

probably you use a function by parameter that call to "event".you must pass $event argument in called function in view



Related Topics



Leave a reply



Submit