If you want to try it, go here
This script is inspired by the blog post of Weston Ruter and the (Modernizr implementation)[https://github.com/Modernizr/Modernizr/blob/master/feature-detects/url-data-uri.js].
If you want to try it, go here
This script is inspired by the blog post of Weston Ruter and the (Modernizr implementation)[https://github.com/Modernizr/Modernizr/blob/master/feature-detects/url-data-uri.js].
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>How to detect the Data-Uri support in javascript</title> | |
<link href="no-data-uri.css" media="screen" rel="stylesheet" type="text/css" /> | |
</head> | |
<body> | |
<script type="text/javascript" src="no-data-uri.js"></script> | |
<body> | |
</html> |
body { | |
background-color: green; | |
} | |
body.no-data-uri { | |
background-color: red; | |
} |
(function(){ | |
var datauri = new Image(); | |
datauri.onerror = function() { | |
document.body.className += ' no-data-uri'; | |
}; | |
datauri.onload = function() { | |
if (datauri.width != 1 || datauri.height != 1) { | |
document.body.className += ' no-data-uri'; | |
} | |
}; | |
datauri.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="; | |
})(); |