EdCharbeneau / BlazorSize

Blazor browser size interop for matchMedia and browser window size at runtime.
336 stars 39 forks source link

How to change browser window size? #88

Closed ZedZipDev closed 1 year ago

ZedZipDev commented 1 year ago

When I start my Blazor server app it shows large browser window. It is not full-screen but it occupied a screen. How can I change the window size ?

EdCharbeneau commented 1 year ago

You cannot change the size of a window opened by a user. This is a web browser behavior introduced as a security feature. The only way to change a browser's window size is by opening a new window via code (JavaScript) and then you may manipulate the size of that window. You can find samples in the e2e test code in the BlazoeSize source.

BlazoeSize is readyonly, it uses web standards. It is a wrapper of the MediaQuery API (matchMedia function). BlazoeSize attaches to browser events and surfaces them in C# so you don't have to write JavaScript.

gragra33 commented 1 year ago

You could look at doing something like this: https://www.w3schools.com/howto/howto_js_fullscreen.asp