Download

HTML default fullscreen

Hello, was wondering if there is a way to make an HTML default to fullscreen or adjust based on window size. I’ve tried setting up Blueprints to run a fullscreen console command upon begin play, as well as a method that I’ve used with other HTML projects (not made in Unreal) in the past, but neither worked. The method for the latter just completely shrinks it, and when adjusting window size, ends up putting the buttons over the game screen and cutting off said screen.

Here’s the different parts of code; Maybe I’m just putting things in the wrong place somewhere.

#mainarea
{
position: absolute;
left: 50%;
top: 50%;
}

#canvas
{
width: 100%;
height: 100%;
}

Then in the JavaScript portion:
function resizeGame()
{
var gameArea = document.getElementById(‘mainarea’);
var widthToHeight = 4/3;
var newWidth = window.innerWidth;
var newHeight = window.innerHeight;
var newWidthToHeight = newWidth/newHeight;

if(newWidthToHeight > widthToHeight)
{
//Our window’s width is too wide compared to the desired width.
newWidth = newHeight * widthToHeight;
gameArea.style.height = newHeight + ‘px’;
gameArea.style.width = newWidth + ‘px’;
}
else
{
//Our window’s height is too high compared to our desired height.
newHeight = newWidth/widthToHeight
gameArea.style.height = newHeight + ‘px’;
gameArea.style.width = newWidth + ‘px’;
}

gameArea.style.marginTop = (-newHeight/2) + ‘px’;
gameArea.style.marginLeft = (-newWidth/2) + ‘px’;

var gameCanvas = document.getElementById(‘canvas’);
gameCanvas.width = newWidth;
gameCanvas.height = newHeight;

}
window.addEventListener(‘resize’, resizeGame, false);