Custom error object not correctly rendered in Chrome - javascript

I have created a custom Error object:
function DialogException(message, data) {
this.name = "DialogException";
this.message = message;
this.data = data;
}
DialogException.prototype = new Error();
DialogException.prototype.constructor = DialogException;
This is the reccomended way of doing it (right?):
[MDN JavaScript Refference]
When throwing this Error:
throw new DialogException('Missing Dialog Settings (dialogDescriptor.dialog).');
Firefox console is showing it this way:
Google Chrome Console is showing it that way:
Can someone please explain why Chrome does not render the custom error object correctly? I would expect an output like the one from Firefox.
Chrome Version: 26.0.1410.64 m
Firefox Version: 19.0.2

Related

Print functionality throws an error saying access denied in IE 11 but works on Chrome with no issues using localhost

Console log error for reference
This is my code:
const height = document.documentElement.clientHeight;
const width = document.documentElement.clientWidth;
const title = 'One-time payment - Billing';
const printWin = window.open(title, title, `width=${width},height=${height},menubar=no,location=no,resizable=no,scrollbars=no`);
if (!printWin) {
return;
}
printWin.focus();
printWin.document.title = title;
printWin.document.write(`<title>${title}</title>`);
When I click on the print button it should open a window with print preview and then let the user print, which works perfectly on Chrome but not on IE 11.
On IE 11 its throwing an error which says Access is denied and opens a new window with 404 error
Also I am running this code on Storybook localhost
Can someone help!
I've tried your code in IE 11 and when I use `` instead of "" it gives me a error of invalid character because IE 11 does not support template literals.
Try change your code to this to see if you can manage it to work:
window.open(title, title, "width="+width+",height="+height+",menubar=no,location=no,resizable=no,scrollbars=no");
and:
printWin.document.write("<title>"+title+"</title>");

DirectLineJS isn't working in FireFox, works in Edge and Chrome

In the chat UI that I made, I connect with directline as indicated in the docs (var directLine = new DirectLine.DirectLine({secret: directLineSecret});) it works perfectly with Chrome and Microsoft Edge, but with firefox it just doesn't connect. When typing in the console the command, it creates a directLine object without a conversation id; therefore, everything that I type doesn't get a response.
Here's is how I create the DirectLine object
Also my listener when posting activities to directLine prints in console a message with the id on success, and the error otherwise, but none of the listeners is executing.
var dlobj = new DirectLine.DirectLine({secret: "myDirectLineSecret"});
var activity = {
from:{
id:"User",
name: "User"
},
type: "message",
text: "I'm here"
};
dlobj.postActivity(activity)
.subscribe(
id => console.log("Success: ",id),
error => console.log("Error: ", error)
);
Output in Chrome:
"Success: A2CflFKTt5j11hPQcDtte|0000001"
In firefox no message is printed, nor error nor success.
Anybody has any idea of the reason this happens?
The only possible cause was, in effect, a difference in permissions of firefox and Chrome.

error from IE9 while creating UserManager in oidc-client.js

I have the following lines in my app.js file:
var settings = {
...
...
};
alert('1);
var mgr = new Oidc.UserManager(settings);
alert('2');
...
Everything works great in every browser except IE9 (and below).
In IE9 '1' comes up and then I get javascript error:
SCRIPT438: Object doesn't support property or method 'apply'
Is it something I am doing wrong or for it to work it must be IE version > 9?
Thank you
Mark

Chrome: Cannot read property 'getAll' of undefined

I'm new to Javascipt and just trying out some examples I found in the net. This one doesn't work at all. I open about:blank in Chrome and use a Console there. When I run this code there's an error Cannot read property 'getAll' of undefined'.
chrome.windows.getAll({populate:true}, getAllOpenWindows);
function getAllOpenWindows(winData) {
var tabs = [];
for (var i in winData) {
if (winData[i].focused === true) {
var winTabs = winData[i].tabs;
var totTabs = winTabs.length;
for (var j=0; j<totTabs;j++) {
tabs.push(winTabs[j].url);
}
}
}
console.log(tabs);
}
Also it seems like chrome doesn't have property windows in it...
That seems like it is using the Chrome Extensions API. You can't just run it in the console. You can get started with Chrome extension development here.

Javascript Console.log Not working in Chrome, or Firefox

I am doing a very simple:
console.log("Testing");
along with :
alert("testing");
The Alert works (so I know the javascript is working) but I'm unable to see the log. When I use Firefox I get the following error:
The Web Console logging API (console.log, console.info,
console.warn, console.error) has been disabled by a script on this
page.
What is going on? I have looked at the following topics, but none have helped:
Chrome: console.log, console.debug are not working
console.log quit working in Chrome
Console.log not working in Chrome [closed]
why does console.log not output in chrome?
Console.log not working at all
I have also made sure that the funnel is working and that logging is turned on.
What else could the problem be?
I just came across this problem after a Firefox update and managed to fix it. Here's the code that caused the problem:
/* IE fix that allows me to still log elsewhere */
if (typeof(console)=="undefined") {
var console = {
output: null,
log: function (str) {
// we can't emulate the console in IE, but we can cache what's output
// so that IE users can get it via console.output
if (!this.output) this.output = new Array();
this.output.push(new String(str));
}
};
window.console = console;
}
In the previous version of FireFox, "var console;" wouldn't get executed. Now it seems to have added some sort of branching/prediction mechanism. Seeing that I may define a variable called console with global scope, it disables window.console.
I fixed this issue by renaming var console; to var cons;
/* IE fix that allows me to still log elsewhere */
if (typeof(console)=="undefined") {
var cons = {
output: null,
log: function (str) {
// we can't emulate the console in IE, but we can cache what's output
// so that IE users can get it via console.output
if (!this.output) this.output = new Array();
this.output.push(new String(str));
}
};
window.console = cons;
}
I still need to test this to make sure it does what I expect in IE, though. I just need to find a copy of IE without a console (I think 9 or below).
I just wish that Firefox would tell you what line of what script disabled the console - that would be nice.
I had the same issue with a Magento e-commerce site (version 1.6.2.0).
I fixed it commenting the following lines in /js/varien/js.js:637
if (!("console" in window) || !("firebug" in console))
{
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {}
}
This fix is only (obviously) for Magento sites.
Turns out the theme developer had added firebug lite to the theme without me knowing. Turning it off fixed the problem.
I think the page you are viewing when trying to log via console.log() has a script in it which overwrites the property window.console.log. Usually this property is preset with a function by the browser but you a script may override it.
First suggestion: Do you use any other dev tools that use console? On Firefox I had the same problem with Firebug running on background without me noticing it, after closing firebug the error went away. Here's a possiple duplicate thread: Firefox Web Console Disabled?
Second, if it is overridden by some script, then one by one disable scripts and see which draws the error.

Categories

Resources