Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (36 sloc) 1.308 kb
<!doctype html>
<html>
<!--
this code was written to demonstrate the script working, please do not judge me on this code as it's fairly messy.
-->
<head>
<title>Demo</title>
<style>
#bodyWidth {
position: absolute; background: rgba(0,0,0, 0.5); font-size: 24px;
top: 0; left: 0;
}
</style>
<script src="responsiveimages.js"></script>
<script>
window.onload = function() {
responsiveImage("img", {
"500" : "http://placekitten.com/500/500",
"600" : "http://placekitten.com/600/600",
"700" : "http://placekitten.com/700/700",
"800" : "http://placekitten.com/800/800",
"1000" : "http://placekitten.com/1000/1000",
"else" : "http://placekitten.com/1200/1200"
}, true);
document.getElementById("bodyWidth").innerHTML = window.innerWidth + "px";
};
window.onresize = function() {
document.getElementById("bodyWidth").innerHTML = window.innerWidth + "px";
};
</script>
</head>
<body>
<img id="img">
<p id="bodyWidth"><p>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.