skmasq
skmasq

Reputation: 4511

Javascript fails in IE when developer tools are closed

I'm debugging my site and when I don't have console open something isn't working and is failing javascript. But when I'm doing same things with developer tools open there suddenly isn't any problems...

How can I see what kind of error occurred if I can't use developer tools?

Upvotes: 2

Views: 267

Answers (3)

Matt Oates
Matt Oates

Reputation: 155

This is a very vague explanation, but perhaps there is some kind of race condition with your javascript, and some events are happening in different orders when you have the developer tools open. (assuming that your code isn't failing because of console not being defined)

Upvotes: -1

spinningarrow
spinningarrow

Reputation: 2436

I had a similar problem: turned out I'd used console.log in my code which was failing when the console was closed.

In your code, you can simply check that the console object exists before using console.log.

Upvotes: 0

Fenton
Fenton

Reputation: 250902

When you close developer tools, there is no longer a console attached, so console.log(...) will fail.

Look in your code for use of console and wrap it in a check:

if (typeof console !== 'undefined') {
    console.log('Message');
}

You could extract this into a function to save typing it everywhere.

Upvotes: 4

Related Questions