Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
1 <!DOCTYPE>
2 <head>
3 <style>
4 body {
5 border: 0px;
6 margin: 0px;
7 padding: 0px;
8 }
9 </style>
10 </head>
11 <body>
12 <img src="image-orientation-viewbox-and-size.svg">
14 <script>
15 var orientation = location.search.substring(1).split("&");
16 var angle = orientation[0];
17 var flip = orientation[1] == "flip" ? true : false;
19 // Construct a style. "from-image" is special-cased.
20 var style;
21 if (angle == "from-image") {
22 style = "img { image-orientation: from-image; }\n";
23 } else {
24 style = "img { image-orientation: "
25 + angle + "deg"
26 + (flip ? " flip" : "")
27 + "; }\n";
28 }
30 // Apply the style to the document.
31 var sheet = document.createElement('style');
32 sheet.innerHTML = style;
33 document.body.appendChild(sheet);
34 </script>
35 </body>