Trouble resizing webplayer

I’m trying to resize my webplayer to fit a user’s browser window. Here’s my javascript in the html header:

	if (typeof unityObject != "undefined") 
{
//get the width of the window
var winW;
if (window.innerWidth)
{
winW = window.innerWidth;
}
else if (document.body && document.body.offsetWidth) //IE
{
winW = document.body.offsetWidth;
}
//set params
var params = 
{	
backgroundcolor: "ffffff",
bordercolor: "ffffff",
textcolor: "000000",
logoimage: "logo_webplayer.png",
progressbarimage: "GUI_loading_filled.png",
progressframeimage: "GUI_loading_empty.png"  	 
};
//embed the player
unityObject.embedUnity("unityPlayer", "fit2cure.unity3d", 1060, 600, params);
//get the player
var unity = unityObject.getObjectById("unityPlayer");
if (unity == null) {
unity = document.getElementById("UnityObject");
}
  if(unity == null) {
unity = document.getElementById("UnityEmbed");
}
//set the width of the player
if (unity != null) 
{
alert("not null");
unity.style.width = winW;
unity.style.height = 600 * winW / 1060;
}
else
{
alert("null");
}
}

Through alerts I’ve figured out that winW is getting the correct width and that despite trying to get the unityPlayer all different ways, it is still null when I try to set the width and height. What else should I try?

You can do this without JS thankfully! :slight_smile:

Just start your webplayer up like this:

unityObject.embedUnity("unityPlayer", "fit2cure.unity3d", "100%", "100%", params);

Then carefully set up all of your container objects to also have maximum width with no padding, border, or margin.

Good luck!

EDIT: on a side note, is it unity.style that is null? instead of unity?