javascript not throwing ReferenceError when using events - javascript-events

UPDATE: This issue cannot be reproduced in Chromium. It seems to be specific to Firefox (both developer toolbar and Firebug).
I have tried disabling all add-ons but still can't get the errors to fire. RUnning Firefox 24.1.1 (mozilla tells me I am using the latest version. This behaviour has been consistent across updates.
I am really new to using events in javascript so hopefully this is an easy fix. But I couldn't sift through all the "error handling" articles when I search for "javascript custom event handler no errors"
When I execute the following code with a syntax error ("consle.log"; no "o"), it fails without throwing any syntax errors
function greetHandler(){
consle.log("Hey bro");
}
document.addEventListener("greet", greetHandler,false);
document.dispatchEvent(new Event('greet'));
However, if I were to use run only:
consle.log("Hey bro");
The console would loudly complain:
ReferenceError: consle is not defined
How can I get that ReferenceError throwing when I am using eventListeners to make my debugging life easier?

Related

Web application written with Processing, using processing.js: how to debug?

I'm a newby in HTML, while I've some skill with Processing language.
I'm writing an application in Processing which I want to visualise in a local webpage.
I've a basic index.html, which upload my sketch and the file processing.js.
It works.
My problem is that sometimes, an application which runs with no proiblem using the Processing IDE, does not run in the webpage. I assume there are still some bugs in the porting from Processing to JavaScript.
What I would like to know is: is there some way to debug the webpage I try to visualise?
Just to seek "where" the webpage remains stuck! In this way I could bypass the problem!
For now, I'm using Firefox for html visualisation.
Thanks a lot, Valerio
Ops solved! I downloaded FireBug, an add-on for Firefox implementing a debugger.
Then I launched the debugger. It showed me immediately the error.
For curious people:
I declared an ArrayList called "foo_list", containing object "foo":
ArrayList<foo>foo_list
The above line does not produce any error in the Processing IDE.
However processing.js complains with it, the debugger displayng
the following message:
ReferenceError: ArrayListfoo_list" is not defined
The solution is to insert a blank space:
ArrayList<foo> foo_list;
This works! Maybe the error given to the parser
from Processing to JavaScript!
Bye!

New firefox + firebug breaks select2 in wrapbootstrap pixel-admin theme

I'm getting a TypeError: elem.dispatchEvent is not a function using select2 in jquery using the wrapbootsrap pixel-admin theme.
It can be reproduced in firebug on the demo site via http://radiant-ocean-4606.herokuapp.com/forms-advanced.html
Firefox Version: 29.0.1
Firebug Version: 1.12.8
It's a similar error message to this question:
"element.dispatchEvent is not a function" js error caught in firebug of FF3.0
But the answer there doesn't help me as my site is all jquery (well as far as I know - I did somewhat accept the theme bundle as it came for the time being until I have time to really rip it apart and modify it in detail).
This was caused by changes to the browser, the solution was to stop using firebug. The features firebug offered are ubiquitous now!

Firefox add-on builder and Jquery Mobile

I am trying everything under my power here to insert jquerymobile.1.0.1 into an extension I have build for firefox.
I can install, link to any other script and everything seems to work just fine, but have had an assortment of errors getting jquerymobile to work.
I've tried uploading through the add-on builder
I've tried remotely linking the file
I've tried copying and pasting the file into other code.. nothing works.
I've coded this extension for safari, chrome and opera without issue, but Firefox chokes the second I link to/include jquerymobile in my code returning this error:
Timestamp: 12-04-27 12:10:33 PM
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHistory.replaceState]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: resource://jid0-d4zlaxz3cfuahkcdoecsmya637m-at-jetpack/idesireit/data/js/jquery.mobile-1.0.1.min.js :: :: line 72" data: no]
and also an error about "unallowed unicode" which I didn't get the chance to copy or paste, but I haven't seen that one in a few saves...
I've read that the above error can be caused by cross domain functions, but all my cross domain functions are in another js file, and they are all working just fine ( judging by those I can navigate to with jquerymobile acting as it is right now )
I'm a novice - if my error is based on my stupidity, please go lightly :O
I went ahead and created an all new extension,
included nothing but the popup, and in that pop up, called jquery and jquery.mobile.
I got this error instantly again.
I'm just going to go ahead and use the alternative UI I'm using on the dashboard widget, I've wasted too much time on this.
The bug is in the addonsdk, not in JQ Mobile. Any attempt to access or manipulate the window.history object in a panel will raise this error.

ASP.NET MVC 3: Microsoft JScript runtime error: Object doesn't support property or method 'addEventListener'

Error context:
Visual Studio 2010 Service Pack 1
ASP.NET MVC 3 Application
IE9 with Script Debugging enabled for Internet Explorer
Error conditions:
Execution stops int a JavaScript file called "script block [dynamic]" at the following line
doc.addEventListener("DOMNodeInserted", onDOMNodeInserted, false);
that line of code is nested inside the following if block
if (ver >= 9.0)
{
doc.addEventListener("DOMNodeInserted", onDOMNodeInserted, false);
doc.addEventListener("DOMNodeInsertedIntoDocument", onDOMNodeInsertedIntoDocument, false);
}
This is a very persistent error that started happening after I re-imaged my hard drive and reinstalled VS 2010 SP1 and ASP.NET MVC 3. I did it twice to make sure I did it right.
I am going to take a guess and suggest that this bug is the side affect of an un-handled exception in ASP.NET MVC 3 or a bug in IE9. The error seems to ocurr when a (GET?) action method cannot be found that is specified in the ActionLink HTML helper method such as
#Html.ActionLink("Link Text", "Action")
I believe that IE9 does support addEventListener so the error itself is incorrect. Unless I can get more info this error is beyond my ability to fix its cause. I can prevent it by making sure that my action method is there and that it works. That is a workaround not a fix. Fixing the error would prevent it from being erroneously reported because IE9 does in fact support addEventListener.
An answer has been found to this question. The problem was caused by the Divix browser plugin
Solution: Object doesn't support property or method 'addEventListener'
Thank you to a poster on the asp.net forums for helping to solve this problem. The Divix browser plugin has recently been updated. The update may have fixed this issue. However, it remains disabled on my system. Disabling the Divx plug-in definitely fixed this issue for myself and others. I have reported this bug to Divx support.
I've been getting this error today while working on a VS 2010 project, I was using IE9 for my browser. Turns out it's an erroneous message, I should have been getting a page not found error. I tried disabling Divx as mentioned above, but that didn't help. I then tried using Chrome and it reported my error correctly and I was able to solve my problem.
If you get this error, try a different browser which may point you in the right direction.
I turned off Compatibility Mode (was running on local intranet) and the problem went away.

New to Ajax programming and need some help

I was told that AJAX would be the best toolbox to use for building the type of application I am interested in creating.
That being the case, I fired up an old copy of Dreamweaver MX2004 I have and started creating the *.htm, *.js and *.php files. However, when I loaded these files onto my server, I was unable to get the program to do anything. I tried to view the program in IE8, if this explains anything.
Where am I screwing up? Do I need to set a certain flag on my bowser?
I look forward to you response.
Does your server have PHP support? What does "unable to get the program to do anything" actually mean? Are you getting error messages? Unexpected results?

Resources