Hey,
I'm new to Javascript and I have a frameset and I need to dynamically change the Sizes of each frame.

How to I do that??

This is my frameset definition::
<frameset rows="8%,87%,5%" >
<frame id="logo" name="banner" src="logo.aspx" noResize scrolling="no">
<FRAMESET cols="73%,27%">
<FRAME id="mainframe" name="mainframe" src="Default.aspx" scrolling="no">
<FRAMESET rows="8%,92%">
<FRAME id="downleftup" name="downleftup" src="querybuttons.aspx">
<FRAME id="downleft" name="downleft" src="layers.aspx">
</FRAMESET>
</FRAMESET>
</frameset>

if you notice the 2 nd Frameset...i have 73% and 27% ..I need to change these values based on various screen resolution...

Dani AI

Generated

Short summary: the split between frames can be changed at runtime from the parent document by updating the frameset's cols or rows attribute with JavaScript, or can be set on the server when the page is generated (as outlines). Server-side output (JSP) requires a page reload to take effect; a client-side script can adjust sizes immediately and respond to window resizes.

A minimal, practical client-side approach is to give the inner frameset an id and change its cols string on load and on resize. The example below shows a simple policy that picks a left/right percentage based on viewport width and applies it safely (property first, setAttribute fallback):

<!-- give the inner frameset an id like id="sideFrames" -->
<script>
function adjustSideCols(){
  var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  var left = (w < 800) ? 60 : (w < 1200) ? 70 : 75;
  var value = left + '%,' + (100 - left) + '%';
  var fs = document.getElementById('sideFrames') || document.getElementsByTagName('FRAMESET')[1];
  if(!fs) return;
  if(fs.cols !== undefined) fs.cols = value;
  else fs.setAttribute('cols', value);
}
window.addEventListener('load', adjustSideCols);
window.addEventListener('resize', adjustSideCols);
</script>

Notes and troubleshooting: use the correct frameset index if not using an id; noresize/noResize only prevents user drag-resize in most browsers but doesn't block script changes; changing cols or rows alters layout without reloading child frames. Test in multiple browsers — framesets are legacy HTML and behavior can vary.

Longer-term recommendation: migrate away from framesets. A responsive CSS layout with two div columns and iframe elements is more robust, accessible, and mobile-friendly (flexbox/grid makes percentage splits trivial and avoids many cross-browser quirks). This also future-proofs the site from the limitations of framesets.

Anybody?I'm still struck with this problem

Anybody?I'm still struck with this problem

you can find the solution on this link


Bye happy coding
Yusuf

If u r using jsp page means v can easily changing the frame size at runtime.

<%!
int size=100;
%>
<frameset border="0" rows="<%size%>,230">
        <frame src="JSP_1.jsp" name="FRAME_NAME_1">
            <frame src="JSP_2.jsp" name="FRAME_NAME_2">
            </frameset>
    </frameset>

If u change the value of "size" that frame size will b change.

commented: Pointless reply to 4 years old thread with weak suggestion -3
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.