-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cross origin error handling #246
Comments
Do you have a link to an article or specification that show how |
Thanks for the link, @szepeviktor. From reading this article (and another from @briancavalier), it seems like we can only add this attribute when we know that the site serving the script has set Some background: scripts have never given any good error reporting, whether or not you use window.onerror or script.onerror or whether the script is remote or not. It'll be nice to get good errors so curl.js can provide something other than "HTTP or Syntax error". :) This feels like an opt-in feature that would be specified on each remote script. Something like this: curl.config({
paths: {
jquery: { location: "//cdn.jquery.com/jquery-2.0.3.min", crossorigin: "anonymous" }
}
}); Thoughts? -- John |
It is very good. curl.config({
crossorigin: "anonymous",
paths: {
jquery: { location: "//cdn.jquery.com/jquery-2.0.3.min" }
}
}); |
All config options can be specified "globally" (although a few don't make sense to be used globally). This one, crossorigin, just seems like it's too error-prone to use it globally. :) |
Do you plan to implement it? |
We're considering it. We don't yet know if async scripts gain any useful error information in their onerror events. Fwiw, a global Is this something you could test for us? Also: it'd be very exciting if this feature prompted the IE team to start firing the script's onerror event, too. (Currently, IE never fires this event handler, which limits the features of script loaders as you can imagine!) /me crosses fingers for an IE12 that doesn't suck. :) |
I plan to report errors to Google Analytics on a small site. Do you think a script loaded from CDN tells you more than "Script error on line 0" on error? |
script.onerror does not fire: window.onerror = function (msg, url, line) {
console.log(msg)
console.log(url + ':' + line)
window.alert("win.onerror fires");
}
var head = document.getElementsByTagName('head').item(0);
var script = document.createElement('script');
script.src = '/f.js' // this contains: idontexist();
script.onload = function() {
window.alert('this works');
}
script.onerror = function() {
window.alert("onerror doesn't fire");
}
head.appendChild(script);
console.log('end.'); |
Do you plan to support |
I've just read that
window.onerror
is not triggered if you use a CDN.Please consider adding
crossorigin="anonymous"
to on-the-fly created script tags.The text was updated successfully, but these errors were encountered: