I need some help to find the frame width and height in a frameset.
I used something like top.[framename].document.body.clientwidth but I'm not getting the clientid when i used top. function???

Dani AI

Generated

As found, getting the frame/window size on the client and sending it back to the server works, but there are more robust patterns today. For and others landing on this thread years later: prefer reading the viewport size from the frame itself, then communicate it to the parent or to your server in a safe, debounced way. Avoid relying on legacy frameset behavior if you can — framesets are obsolete in modern HTML.

To measure the visible area reliably use the window viewport or element bounding box rather than fragile layout assumptions. window.innerWidth / window.innerHeight measure the viewport; getBoundingClientRect() gives an element’s rendered box (useful if you need a specific container). See the docs for details: Window.innerWidth and Element.getBoundingClientRect.

If the frame and parent are different origins, do not try to read the other DOM directly. Use postMessage to send size data from the child to the parent, and have the parent validate the origin before using the data. Example pattern (child -> parent):

var size = { w: window.innerWidth, h: window.innerHeight };
window.parent.postMessage(size, "https://your-parent-origin.example");

Parent listens and forwards to the server as needed:

window.addEventListener("message", function(e) {
  if (e.origin !== "https://your-parent-origin.example") return;
  var size = e.data;
  // send to server with fetch(), or update layout
});

See Window.postMessage and the same-origin policy. For continuous updates use a debounced resize handler or ResizeObserver to avoid flooding the server. Finally, if the goal is responsive layout, prefer CSS media queries and fluid design so the server rarely needs exact pixel sizes.

Yeah i got the answer..to get the height and width of the window inside the frame by using
in the Javascript..

mapframeheight = document.body.clientHeight;
mapframewidth = document.body.clientWidth;

And I sent these values to the server by using something like a query string...
windid = window.open("default.aspx?frameheight="+mapframeheight+"&framewidth="+mapframewidth+"","mainframe");

hi -i need some frame for get size of height

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.