Resizing frames in Javascript

Last century I wrote a website that uses frames. (Main navigation on the left,alphabet search on top, and a main content frame below). The design is out dated, and should probably one day be rewritten in flexbox or Grid. But this is not the primary motivation for this question. I also need to add a little more history. The site’s html is still functional with modern browser, but suffers from being trapped in the post CRT monitor revolution in which screens larger than 1024 pixels once unimaginable, are now common place. The site has many low res images/formatting tricks due to being created in the days of dailup 56k internet. If I load the site in a 1920w monitor it looks crap, but if I create an additional frameset and load the site into a right frame no bigger than 1024 px the site works with a sense of what it looked like in the past. My goal is to modify the content of the original site (c1999-2023) as little as possible.

The problem:
I am trying to create a client side script that automatically detects a users monitor size and writes a frameset (or something – DIV CSS?) with three columns. A central column of 1024px and columns to the left and right of the central that are 1/2 the size of the remaining space.

<script>
function calculatePercentage(part, total) { 
    return (part / total) * 100; 
} 

function round(
  value,
  minimumFractionDigits,
  maximumFractionDigits
) {
  const formattedValue = value.toLocaleString('en', {
    useGrouping: false,
    minimumFractionDigits,
    maximumFractionDigits
  })
  return Number(formattedValue)
}

let part = ([window.innerWidth-1024]/+2);
let max = 1024; 
let ttotal = (window.innerWidth);
let percentageC = calculatePercentage(max, ttotal);
let percentageS = calculatePercentage(part, ttotal);
let v = [(100-[round(percentageC,0,0)])/2]+ "%";
let w = round(percentageC,0,0) + "%";
let columns = [v,w,v];
</script>
``
Below is the output I am hoping to insert into the frameset, but expressed as a document.write test statement;

document.write(‘cols=’+'”‘+(columns)+'”‘+’>’);

Below is the result:

cols=”22.5%,55%,22.5%”>

The insert target is a Frameset HTML that looks like this:

<frameset cols="22.5%,55%,22.5%">
<frame src="right.htm" name="right" frameborder="0" scrolling="no" marginwidth="0" marginheight="0">
<frame src="centre.htm" name="centre" frameborder="0" scrolling="no" marginwidth="0" marginheight="0">
<frame src="left.htm" name="left" frameborder="0" scrolling="no" marginwidth="0" marginheight="0">

(with: “cols=”22.5%,55%,22.5%” entered manually).

By standing on the shoulders of giants:

A have been able to come up with a script that redirects monitors less than 1024 to the original web frameset and redirects them to the original index page.

I have a script (above) that detects a users monitor size subtracts 1024 from total screen width: divides that figure by 2: and, outputs the three column sizes as a percentage (to no more than 1 decimal place so that the total of the 3 columns always adds up to 100.

What I can not do is insert this information into a frameset that will then auto load the three columns.
The script works,it will display if inserted into a normal HTML page but can not get anywhere with a frameset. I have two possible ways to proceed (I sure that 20 years ago a could get a browser to document.write into a frameset page?)

use an id tag and reload the page, but I can not see how to use this without the requirement to manually post a form?

reload the page and get the variable to persist and write the function preloaded into a cols destination of a frameset on another page?

However I am not confident that these approaches will work.

This is the redirect script for low res monitors and an early discontinued attempt at resolving the problem

<script>
if (screen.width <= 1024) {
document.location = "control.html"
<!--
else
      function myFunction() {
  let num = ([window.innerWidth-1024]/2);
   } 
-->
  </script>
 

New contributor

David is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật