I'm trying to have my game scale down based on the resolution of the player's browser window. By default it runs at 1280x720 which would be too big for small laptops or other smaller screens.
Before the game starts I scale down the canvas based on the window's width. Which works fine locally. On itch.io I have to access the parents window's width since the game is within a IFrame.
I found an answer StackOverflow to get the parent's width with : parent.window.innerWidth
But that only works if the IFrame is on the same domain.
I got this error trying it:
"Uncaught DOMException: Blocked a frame with origin "https://v6p9d9t4.ssl.hwcdn.net" from accessing a cross-origin frame."
The same StackOverflow thread mentioned to use Window.postMessage() for IFrames from a different domain.
Could a feature be added for web games to access its parents window resolution? Is there a another way to scale down my game's resolution dynamically?
Plan B. Is just to have a Low, Medium and Height Resolution buttons and have the players choose. Which isn't too bad.
Image illustrating whats happening: