Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: pages/index.html

Issue 29322731: Issue 2710 - Attach window dimensions to root element if run in top level frame (Closed)
Patch Set: Created July 21, 2015, 4 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pages/index.html
===================================================================
--- a/pages/index.html
+++ b/pages/index.html
@@ -115,9 +115,6 @@
function sendDimensions()
{
- if (window.parent === window)
- return;
-
var dimensions = {
width: document.body.offsetWidth,
height: document.body.offsetHeight
@@ -127,7 +124,16 @@
if (/MSIE/.test(navigator.appVersion))
dimensions = JSON.stringify(dimensions);
- window.parent.postMessage(dimensions, "*");
+ // If this is the top frame we cannot use postMessage so we leave it up to
+ // the actual top frame to grab the dimensions from the root element
+ if (window.parent === window)
+ {
+ var rootElement = document.documentElement;
+ rootElement.setAttribute("data-width", dimensions.width);
+ rootElement.setAttribute("data-height", dimensions.height);
+ }
+ else
+ window.parent.postMessage(dimensions, "*");
}
window.addEventListener("DOMContentLoaded", function()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld