0

I have a strange problem with my IDE. I'm using IBM RAD8.0 version with Websphere 8.0. I'm using a jQuery library version 1.9.1 in my application. I see that when I started using 'console.log' key word to display debug messages my IDE won't run jQuery at all at the same time if I launch my app using external IE it detects my jQuery code and executes the app normally!! When the keyword 'console.log' is replaced with 'alert' then the RAD 8.0's internal browser detects the jQuery code and executes normally. Why is RAD local browser weary of 'console.log' keyword?

This is how I'm importing the jquery file into my JSP page.

    <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/javascript/jquery-1.9.1.js"></script>
pnuts
  • 58,317
  • 11
  • 87
  • 139
kkk
  • 166
  • 2
  • 18

1 Answers1

2

The console is an object provided by some browsers. Evidently the RAD internat browser does not support it.

You could solve the problem adding this javascript code inside your page

if (!console) {
    console = {};
    console.log = function(msg) {alert(msg);}
}

This way if the browser you are currently using does not support the console object it will use the alert function instead.

Luca Putzu
  • 1,438
  • 18
  • 24
  • Alternatively there are bookmarklets that add in a console object and readout; Firebug Lite springs to mind https://getfirebug.com/firebuglite . This does of course assume that RAD8.0 supports bookmarklets. – Robin Whittleton Aug 22 '14 at 14:46
  • 1
    @Robin: sure, and i suggest them... but if you are writing down an application and your client user agent doesn't work as expected because of a console.log, i'd patch my code instead of suggesting to patch his user agent... Call it marketing, if you want :) – Luca Putzu Aug 22 '14 at 16:11
  • True, but as Firebug Lite is pure JS there’s nothing stopping you installing it as a library in your application (at least in debug mode). – Robin Whittleton Aug 23 '14 at 15:51
  • @LucaPutzu Even after manually handling the console object to display an alert instead, RAD8's browser won't pick it up. So I'm still on the same page, including any 'console' words inside my jQuery will make my internal broswer dummy. External browsers are accepting the same application/jQuery code. – kkk Aug 25 '14 at 13:18