Skip to content

Instantly share code, notes, and snippets.

@airios
Created June 24, 2011 00:35
Show Gist options
  • Save airios/1043981 to your computer and use it in GitHub Desktop.
Save airios/1043981 to your computer and use it in GitHub Desktop.
Y.Get does not fail with Webkit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Y.Get Example</title>
<script src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
</head>
<body>
<h1>Y.Get Example</h1>
</body>
<script type="text/javascript">
YUI().use(function(Y) {
// This should fail for Safari
var ua = Y.UA,
url = (ua.webkit) ? "http://yui.yahooapis.com/combo?3.3.0/build/yui/yui-min-oops.js" : "http://yui.yahooapis.com/combo?3.3.0/build/yui/yui-min.js";
obj = Y.Get.script(url, {
onSuccess: function() {
alert("Success!");
},
onFailure: function(e) {
alert("Failure!");
}
});
});
</script>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Safari onLoad Working Example</title>
</head>
<body>
<h1>Safari onLoad Working Example</h1>
</body>
<script type="text/javascript">
(function(){
var n = document.createElement('script');
n.addEventListener("load", function(){
alert("Success! Loaded URL.")
});
n.addEventListener("error", function(){
alert("Failed to load URL.");
});
n.async = "async";
n.type = "text/javascript";
n.src = "http://yui.yahooapis.com/combo?3.3.0/build/yui/yui-min-oops.js"
document.getElementsByTagName('head')[0].appendChild(n);
})();
</script>
</html>
@aaronpeters
Copy link

Do you mean my test page works fine in those browsers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment