Can anyone make sense of this apparent contradiction?
Please look at the following screen shot.
The debugger shows the correct error object but the roll over shows the parameter to be null. The latter appears to be the actual state because no error text gets logged to the log file but the debugger shows what should be there!
It's a bug. Please follow WEB-13863 for updates
Related
I'm a blind learner. I want to test an expression like
console.log(1 + 2);
function myFunction() {
var a = 1 + 2;
}
console.log(myFunction());
But it is not showing me anything (not even errors).
I don't know if that is an accessibility issue.
My browser is up-to-date.
Any help will be greatly accepted.
Google Chrome does not make it easy for a visually impaired person to see the result of a console.log() statement in their Developer Tools Console.
I used NVDA in my experiments. Your experience in other screen readers may be different.
I entered console.log(1+2) and pressed Enter.
I pressed Shift+Tab.
This read "undefined", as that is the return value of console.log().
I pressed Left Arrow once.
This read "three".
I can't imagine the experience of reading anything more complex would be. Good luck.
Navigating and using developer tools is difficult at first with a screen reader, but it doesn't take long to get used to it.
First, have a read of this document from Google on devtools shortcuts you will find there are loads of shortcuts that you can use. This makes it easy to get used to navigating the console.
How to navigate in your example.
What is confusing when you are not used to it is that the text that is logged to the console is attached to the line and character declaration (so for example it may read "VM50:1 3", explained below)
So in your example above you navigate to the previous item (shift + Tab) to get undefined as that is still what console.log(1+2) will return.
Then if you press the Up arrow it will focus a link and announce "link vm50:1 3" where "link vm50:1" is line and character number and "3" is the answer.
An easier way to understand this is to log some words to the console instead, if you log "I like cheese, it is yummy" you will get something like "VM50:1 I like cheese, it is yummy"
One thing that can be confusing is when you get an error that results in a stack trace (as we are reading from the bottom to the top). For that I tend to spam the up arrow until I don't hear "at" and get a script name as that will announce the error as well.
Finally try navigating via links (Shift + K in NVDA) as that can also be a quick way to get to errors (although can be confusing if you get a stack trace as above).
The case like this :
My code in the console like that. So I found it hard to make a breakpoint
How can I solve this problem?
just use debugger; in your javascript code, then open browser debugger console and trigger the code, so automatically debug pointer will point at your exact position of code.
for more details read
This is what my debug console looks like in chome:
Thing is, I'm using a WebGL framework do draw everything and I don't have the means to debug it. My app works well despite some vertices being out of range / off-screen. Can I just silence the warnings so that people who visit my website don't see them (and so that I can debug the site without this spam)?
EDIT
I know it's always better to fix the bug than shut up the message. However in this case I've confirmed that the problem was likely with my graphics card (specifically, the problem was fixed after I stopped a bitcoin miner that was running on my computer). Before downvoting, consider that a google search on this topic doesn't currently have very many useful results. Thanks.
There is no way to turn off the error messages. You have to just stop doing whatever it is that's generating the error
That bug means something isn't getting drawn. Since you clearly don't care if it's getting drawn or not then stop trying to draw whatever it is that causing the error message.
To find out what that is bisect. Remove half the things you're drawing. If you don't get the error any more then the issue is one of the half of the things you removed. If you still get the error remove the other half. Do you still get it? if that removes the error you know the issue is in the second half of stuff you removed.
Now remove the half of the half and so on. Keep doing that until you find the object(s) that are causing the error. Since they weren't being drawn anyway just remove them from your code.
I don't think there is a way to turn it off unless you want to maybe override console.warn in your global object and suppress warnings
console.warn = function() {}.bind(console.warn);
console.warn('warning'); // nothing gets printed
you could try overriding console.log/warn globally, if you don't need the console for any other reason just assign it to an empty function
console.log = function(){};
If you still need the console for other messages you could try with an if statement:
let newConsoleLog = console.log;
console.log = function(message){
if (message !== "message that you dont want logged"){
newConsoleLog(message)
}
}
I'm working in a large project that was developed for several years and had tons of code. Recently uninformative alert start to appear. It just says Undefined. I need to find the source of this alert. Is the any chance to make something like "breakpoint on alert"? I want to see the source of this alert.
One possibility is to redefine alert function. I tried to make it in firefox without any success.
I'd go with redefining window.alert right at the start of the code for this type of development purposes.
window.alert = function(e){ console.warn( "Alerted: " + e ); }
This will give You a line number for sure. ( Tested on chrome console )
This is an old question, but thought I would help out with a simpler solution. A very easy way in Chrome to find the source is by placing a debug in the console on window.alert:
debug(window.alert)
This will break on alert and take you to the source. In general, using console with debug(fname) will break whenever the function fname is called.
As a continuation to Vsevolod's method, in FireBug over Firefox for example, you could place one conditional breakpoint on each and every alert(), and see which one fires off, then go up the callstack shown by FireBug.
The condition could be "typeof whatever_variable_is_displayed == 'undefined'".
I am trying to become better with JavaScript and I have done a great job at breaking a page really badly :)))))
I am trying to use Firebug to debug, but it is a little confusing at first. Which of its tabs is used to debug JavaScript? I see DOM and Script - which should it be?
My general problem is this page:
http://www.comehike.com/outdoors/trees/add_spotted_trees.php?hike_id=108
I made a login for people:
login: test#comehike.com
password: password
What I was trying to do on that page is to get the "clear all" and "clear last" links to work correctly, but I just created a hit mess :)
What happens now is that markers are placed, but after "clear all" the markers aren't recognized and not put into the "rout_markers" id element.
Any clues on how I can get this resolved or at least heading in the right direction?
Much appreciated!
You need to be watching the Console tab for errors and warnings. For instance, you have two I've seen:
On page load:
YUI is not defined
http://www.comehike.com/outdoors/trees/add_spotted_trees.php?hike_id=108
Line 256
After logging in and clicking Remove All Markers:
markers[array_length - 1] is undefined
http://www.comehike.com/outdoors/trees/add_spotted_trees.php?hike_id=108
Line 322
Also, instead of using alert() to test, you can use console.log(), which will print to the console. Just remember to remove these before going live.
In addition, you may want to check out some videos:
http://www.virtuosimedia.com/dev/javascript/15-essential-javascript-video-tutorials
And go through some tutorials:
http://www.softwareishard.com/blog/category/firebug-tutorial/
EDIT
Following my comment, here is what I have done to combat the console.log() conundrum:
try{console.log();}catch(e){var console=new Object;console={log:function(){ininklklaskjdflk=0;}};};
Just to add to what Jared says, using console.log() is a much more efficient way of debugging that alerting everything. However, if you leave this in and visit the page in a browser that doesn't have a console, it will crash. You can just remove the console.log() calls, or if you are worried about forgetting those, you can just use this little piece of code:
if(window.console && console.log) console.log("Log Something");
All that does is check a console exists before sending something to it. If the console doesn't exist, that if statement will evaluate to false, meaning console.log("Log Something") is never run. If you liked you could also write this like so:
if(window.console && console.log) {
console.log("Log Something");
}
Both mean exactly the same thing.
The script pane lets you look at the source of all the javascript running on the page. And you can setup breakpoints and look at variables....
The Console Pane is probably the most useful.
You use it to see errors and console.log statements (from Jack Franklin's Post). You can also run javascript from a "command line" to test it on the page.