Javascript error messages missing - javascript

Javascript containing errors sometimes does not execute without any error message. The following line for example gives a syntax error "missing ; before statement" if you type it in the Firebug console, because it contains a quotation mark at the wrong place:
window.location.href = "some_url?param1="+12+"+"param2="+13
But if you use it on web page, then sometimes the Javascript block which contains it will not execute at all without any error messages in the Firebug console or elsewhere (using Firefox 10.0). In my case I used this example in an OnClick event handler of the fullCalendar jQuery plugin to load a new page if the user clicks on a certain date. How it is possible to force Javascript to enable the display of suitable 'unobtrusive' error messages for Firefox (or Firebug) ?

It depends of course upon the browser you are using if errors messages are displayed or not. IE gives warnings, Firefox does not. Plugins like Firebug or the Web Developer extension come to the rescue here. If you are using Firefox's Web Developer extension you may see a red exclamation mark in the far right of the toolbar when a JavaScript error has occurred. Click on it to open the Error Console.
Firebug is able to show Javascript errors in the "Console" tab, but only if "Show JavaScript" Errors is activated (on Linux select the "Console" tab and click on the right arrow next to "Console" and check the option "Show JavaScript Errors")

Related

Firebug 2+ Add-on Doesn't Show Error Info

Please see attached image for reference. Until very recently, Firebug add-on in Firefox would show a red error count on top right and the Console would have the javascript error info.
But looks like Firebug is no longer supported and is being integrated inside Developer Tools: https://developer.mozilla.org/en-US/docs/Tools/Migrating_from_Firebug and for that link you'd see that the error count only could be now displayed but only after pressing Shift+F2 keys - and even then error info not displayed.
I would like to see the error count red as soon as the page loads. I'd also like to see error info in the 'errors' tab of the Console, as it used to be. I have looked for a solution - even tried to revert to older Firebug but so far no success.
Any idea?
Your screenshot obviously shows the Firefox DevTools (with Firebug theme) and not the Firebug.
To see the JavaScript errors in the Web Console you need to toggle the related filter. To do that click the button in the console toolbar.
Having said that, there's a bug regarding the error count causing the number shown in the Developer Toolbar to be wrong, i.e. it often doesn't match the number of errors logged to the console.
Never mind,
Per this post: How to revert Firebug to old version?
I set all instances of browser.tabs.remote.autostart to false and Firebug seems to be working as it was before.
This maybe temp solution but it fixes my problem :)
HTH

Prevent chrome console from processing javascript until I'm finished writing it

Is there a way I can set up javascripting in Chrome's console so that it does not process my statement as soon as I hit return. If I'm trying to test something out by just writing some javascript there, it processes before I'm done writing.
//here I am writing in the console
if ($(el).size() === 0){
//now I hit return because I want to type some stuff if this evaluates to true
//but return submits it as a finished piece of javascript and of course
//I get SyntaxError: Unexpected end of input before I can have a chance
//to finish the logic
I know I can hit shift+return and get a line break, and though that's a small inconvenience, it's still a bit of an inconvenience. Is there anyway I can tell it to hold off processing until I hit a macro like shift+return?
It's the same way in Firebug. Maybe there's an option there. Or maybe someone knows of a good third party add-on. Thanks.
In the comments I posted the ticket for the request for support, but it has been there for awhile. Chrome does have snipplets, but you have to enable them.
In the address bar type about:flags
Enable Developer Tools experiments
Restart the browser
Open the Developer Tools open the settings menu [gear on bottom right corner]
Click the Experiments tab [on left], check Snippets support
Restart the browser
In the Scripts panel, there will be a Snippets tab, click on it.
Right click on the area below and from context menu select New
You can than Edit and Run the code like a file. Run it with the context menu or play button.
A multi-line console effectively lets you do what you want. Chrome has a request for this but is otherwise not really available.
Firebug Lite for Chrome does allow it. Just click the little red button at the bottom-right of the Javascript console.

Open firebug inscpector using javascript

From a bookmarklet I need to open firebug and inspecting an element.
I know firebug got a command "inspect" but it seems it's not possible to execute this command from javascript.
Firebug can be driven using the new firefox command line ...but it seems we can not execute command line from javascript.
If you have an idea?
I have a bookmarklet which finds errors in the HTML code. The bookmarklet lists all elements in error. If user clicks on an element, I would like to display it in firebug inspector.
Not sure what exactly you are trying to achieve here. If you are trying to debug your own code then use javascript "debugger" command to cause firebug to break on a given line of code.
If you are looking to trigger Firebug to open at an end user's browser then this would cause confusion for the user and also this option could possibly be a security risk.
Anyway if firebug is deactivated then it can't respond to anything so you wouldn't be able to do this.
You can open FireBug just by pressing F12 in the browser

Debugging javascript in ascx control

I am using javascript for an ascx control in my application.
I am getting some errors and want to debug the same.
I have put the debugger in my javascript and unchecked disable script debugging for internet explorer.
When my script is getting executed, I get the debugger launched, and when I attach the javascript (here it is in a separate file ), There is a message as,
There is no source code available for the current location.
What could be going wrong here.
I hope to get some tips on debugging javascript with ascx control
To debug Javacript embedded in a ascx control, you can use chrome explorer.
Here is the step.
Open the page that has the user control in it.
Press F12 on that page.
go to Sources in the "DevTools"
Find pages in the "Sources" tab
click on the page name that you are debugging.
you will see the source code in the middle pane.
your user control javascript is included in the page's source code, this is the key.
use Ctrl + F to find that javascript by the method name you want to debug
add breakpoints to that method and debug
Hope it helps.
To debug JavaScript, Hit f12 in your browser. This will open the developer tools in most browsers. (with Firefox, this assumes you've already installed firebug, which has to be installed separately as an add-on.)
Select the script tab, set your break points by clicking the margin to the left of the line of code where you want to break. If you are using IE, click "start debugging". Then perform an action on your page that will trigger your code. Happy debugging.

How to view detailed Script errors instead of in IE

When there is a Javascript error in IE I get an 'Errors on this page may not work correctly' by clicking the tray in the bottom left corner. I've used Firebug and couldn't find anything that could do it yet. Maybe i'm missing something, or is there anything else that offers the same type of functionality of IE script errors, but instead of showing the just the error line #, it will also possibly show a snipped of the code or elaborate a bit more?
In Firefox/Firebug, you can right-click on an element in your browser page and select Inspect Element with Firebug. Once Firebug is open, click on the Console tab. In the console tab, you can choose what kind of errors you want to see. Javascript errors will show with either "All" or "Errors" selected.
It will show you the line number of the error, the error message and give you a link you can click on to open that part of the javascript source so you can see exactly where the error occurred.
There are some types of parse errors where the error is discovered many lines after the cause so the extra line it points to is not always correct. For javascript execution errors, the exact line should always be correct.
The newer versions of IE have something similar builtin. If you press F12, the IE debug console window opens and you can see similar information there.
Chrome and Safari also have a debugger and error console built in.

Categories

Resources