Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Resize-notifying IFRAME</title> |
michael@0 | 5 | <script type="application/ecmascript"> |
michael@0 | 6 | |
michael@0 | 7 | var gTarget; |
michael@0 | 8 | |
michael@0 | 9 | /* |
michael@0 | 10 | * the test is done after the width becomes narrower (immediately) |
michael@0 | 11 | * and then comes back to the same size. However, the two things |
michael@0 | 12 | * might happen at once. |
michael@0 | 13 | */ |
michael@0 | 14 | function arm() { |
michael@0 | 15 | gTarget = window.innerWidth; |
michael@0 | 16 | window.addEventListener("resize", got_resize, false); |
michael@0 | 17 | setTimeout(got_resize, 200); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | function got_resize() { |
michael@0 | 21 | if (window.innerWidth == gTarget) { |
michael@0 | 22 | gTarget = -1; |
michael@0 | 23 | // Remove the class="reftest-wait" from the top window |
michael@0 | 24 | window.top.document.documentElement.removeAttribute("class"); |
michael@0 | 25 | } |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | </script> |
michael@0 | 29 | </head> |
michael@0 | 30 | <body> |
michael@0 | 31 | </body> |
michael@0 | 32 | </html> |