Hey Y'all, I made a solution. Try this, and let me know if you have questions.
Premise: A small javascript that reads the size of the window, passes that variable to width property of CSS.
Insert this into a code block on your squarespace page that hosts the iframe.
You will also need to add a bit to your Custom CSS page ((see next post))
<!-- Copy and paste all of this code into a code block on your squarespace page— make any necessary adjustments to numbers-->
<!-- Desktop Version of your iframe -->
<iframe src="https://www.___YourWebsiteHere.com"
class ="frame desktop"
id="desktopFrame"
scrolling="yes">
</iframe>
<!-- Mobile Version of your iframe -->
<iframe src="https://www.___YourWebsiteHere.com"
class="frame mobile"
id="mobileFrame"
scrolling="yes">
</iframe>
<!-- Javascript code to retrieve width of window and convert it to CSS property -->
<script>
// This function changes one scale of numbers to another scale of numbers - it's used later
// heres a good expalination how it works: https://www.youtube.com/watch?v=nicMAoW6u1g
const scale = (num, in_min, in_max, out_min, out_max) => {
return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
var r = document.querySelector(':root');
var frameScale;
// Call a function to scale iframe when window opens or resizes
window.onload = frameScaler();
window.onresize = function(){frameScaler()};
function frameScaler(){
// page-body is the main div that holds squarespace content
var contentWidth = document.getElementById("page-body").offsetWidth - 300;
// This is the function— takes current page width (contentWidth)
// Then minimum and maximum expected values for the page content as pixels
// and minimum and maximum expected values as decimal percentages
// you can play with the last 4 numbers to make it work for your page
frameScale = scale(contentWidth, 400, 2100, .2, .8);
// Sets CSS prperties, desktop and mobile
r.style.setProperty('--scaled', frameScale);
r.style.setProperty('--scaledMobile', frameScale*11);
// Sets another CSS property
contentWidth = contentWidth / 2500 ;
//contentWidth = contentWidth + 'px';
r.style.setProperty('--contentWidth', contentWidth);
};
</script>