100% sizing in web build not working properly in firefox

My friend posted this a while ago

The web page in question is: http://dl.dropbox.com/u/25260770/TacticsEnsembleTest/WebPlayer.html

I’ve set the sizing to “100%” and it works fine in Chrome, the problem just happens in Firefox.

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

I need it to be 100% instead of supplying the current window size so that the unity display will still fit even if the browser window is resized.

Seems to be the problem is with Firefox and not Unity. Any idea how to fix this?

i’m having this problem with Firefox 5 and Opera 11.5 on OsX 10.6.8, the player height is fixed at 150px.
Safari and Chrome work fine…

fuond a solution here

That link didn’t really help, so I guess I just have to do a workaround so Firefox browsers will just use the window height and width values instead of 100%. The downside is if the user resized the window, Unity won’t be able to detect that.

Here’s some rough code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Unity Web Player | WebPlayer</title>
		<style type="text/css" media=screen>
		body
		{
			margin: 0px;
			padding: 0px;
			font-family: Helvetica, Verdana, Arial, sans-serif;
			background-color: black;
			color: white;
			text-align: center;
		}
		</style>
		<script type="text/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js"></script>
		<script type="text/javascript">
		<!--
		function GetUnity() {
			if (typeof unityObject != "undefined") {
				return unityObject.getObjectById("unityPlayer");
			}
			return null;
		}
		if (typeof unityObject != "undefined") {
			var params = {
				disableContextMenu: true
			};





			var BrowserDetect = {
				init: function () {
					this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
					this.version = this.searchVersion(navigator.userAgent)
						|| this.searchVersion(navigator.appVersion)
						|| "an unknown version";
					this.OS = this.searchString(this.dataOS) || "an unknown OS";
				},
				searchString: function (data) {
					for (var i=0;i<data.length;i++)	{
						var dataString = data[i].string;
						var dataProp = data[i].prop;
						this.versionSearchString = data[i].versionSearch || data[i].identity;
						if (dataString) {
							if (dataString.indexOf(data[i].subString) != -1)
								return data[i].identity;
						}
						else if (dataProp)
							return data[i].identity;
					}
				},
				searchVersion: function (dataString) {
					var index = dataString.indexOf(this.versionSearchString);
					if (index == -1) return;
					return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
				},
				dataBrowser: [
					{
						string: navigator.userAgent,
						subString: "Chrome",
						identity: "Chrome"
					},
					{ 	string: navigator.userAgent,
						subString: "OmniWeb",
						versionSearch: "OmniWeb/",
						identity: "OmniWeb"
					},
					{
						string: navigator.vendor,
						subString: "Apple",
						identity: "Safari",
						versionSearch: "Version"
					},
					{
						prop: window.opera,
						identity: "Opera"
					},
					{
						string: navigator.vendor,
						subString: "iCab",
						identity: "iCab"
					},
					{
						string: navigator.vendor,
						subString: "KDE",
						identity: "Konqueror"
					},
					{
						string: navigator.userAgent,
						subString: "Firefox",
						identity: "Firefox"
					},
					{
						string: navigator.vendor,
						subString: "Camino",
						identity: "Camino"
					},
					{		// for newer Netscapes (6+)
						string: navigator.userAgent,
						subString: "Netscape",
						identity: "Netscape"
					},
					{
						string: navigator.userAgent,
						subString: "MSIE",
						identity: "Explorer",
						versionSearch: "MSIE"
					},
					{
						string: navigator.userAgent,
						subString: "Gecko",
						identity: "Mozilla",
						versionSearch: "rv"
					},
					{ 		// for older Netscapes (4-)
						string: navigator.userAgent,
						subString: "Mozilla",
						identity: "Netscape",
						versionSearch: "Mozilla"
					}
				],
				dataOS : [
					{
						string: navigator.platform,
						subString: "Win",
						identity: "Windows"
					},
					{
						string: navigator.platform,
						subString: "Mac",
						identity: "Mac"
					},
					{
						   string: navigator.userAgent,
						   subString: "iPhone",
						   identity: "iPhone/iPod"
				    },
					{
						string: navigator.platform,
						subString: "Linux",
						identity: "Linux"
					}
				]
			
			};
			BrowserDetect.init();



			var viewportwidth;
			var viewportheight;
			
			// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
			
			if (typeof window.innerWidth != 'undefined')
			{
				viewportwidth = window.innerWidth,
				viewportheight = window.innerHeight
			}
			
			// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
			
			else if (typeof document.documentElement != 'undefined'
			     typeof document.documentElement.clientWidth !=
			    'undefined'  document.documentElement.clientWidth != 0)
			{
				viewportwidth = document.documentElement.clientWidth,
				viewportheight = document.documentElement.clientHeight
			}
			
			// older versions of IE
			
			else
			{
				viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
				viewportheight = document.getElementsByTagName('body')[0].clientHeight
			}

			var uw = "100%";
			var uh = "100%";

			if (BrowserDetect.browser == "Firefox" || BrowserDetect.browser == "Opera")
			{
				uw = viewportwidth;
				uh = viewportheight;
			}

			unityObject.embedUnity("unityPlayer", "WebPlayer.unity3d", uw, uh, params);
			
		}
		-->
		</script>
		<style type="text/css">
		<!--
		a:link, a:visited {
			color: #000;
		}
		a:active, a:hover {
			color: #777;
		}
		p.header {
			font-size: small;
		}
		p.header span {
			font-weight: bold;
		}
		p.footer {
			font-size: x-small;
		}
		div.content {
			margin: 0px;
			padding: 0px;
			height: 100%;
			width: 100%;
		}
		div.missing {
			margin: auto;
			position: relative;
			top: 50%;
			width: 193px;
		}
		div.missing a {
			height: 63px;
			position: relative;
			top: -31px;
		}
		div.missing img {
			border-width: 0px;
		}
		div#unityPlayer {
			margin: 0px;
			padding: 0px;
			height: 100%;
			width: 100%;
			cursor: default;
		}
		-->
		</style>
	</head>
	<body>
		<div class="content">
			<div id="unityPlayer">
				<div class="missing">
					<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
						<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
					</a>
				</div>
			</div>
		</div>
	</body>
</html>

at the bottom of the page you can find this link:
http://dat.marsxplr.com/play
in the source of that page, you see that they use the “100%” as values and it works (at least for me) both in opera and firefox…

this is my webplayer template so far:

<html>
	<head>
		<style type="text/css">
		body {
			text-align:center;
			background-color: black;
			background-position: center top;
			background-repeat: no-repeat;
			background-image: url(http://www.yoursite.com/background.png);
			overflow:hidden;
		}
		body, object, embed, a {
			padding:0;
			margin:0;
			outline-width:0;
			color: white;
		}
		#missing {
			padding-top: 250px;
			height:400px;
			background-position: center top;
			background-repeat: no-repeat;
			background-image: url(http://www.yoursite.com/background.png);
		}
		</style>
		<title></title>
		<script type="text/javascript" src="%UNITY_UNITYOBJECT_URL%"></script>
		<script type="text/javascript">
		<!--
		function GetUnity() {
			if (typeof unityObject != "undefined") {
				return unityObject.getObjectById("unityPlayer");
			}
			return null;
		}
		if (typeof unityObject != "undefined") {
			var params = {
				backgroundcolor: "000000",
				bordercolor: "000000",
				textcolor: "FFFFFF",
				logoimage: "http://www.yoursite.com/logo.png",
				//progressbarimage: "http://www.yoursite.com/logo.png",
				//progressframeimage: "http://www.yoursite.com/logo.png",
				disableContextMenu: true,
				disableFullscreen: false,
				disableExternalCall: true
			};
			unityObject.embedUnity("unityPlayer", "%UNITY_WEB_PATH%", "100%", "100%", params);
		}
		-->
		</script>
	</head>
	<body>
		<div id="unityPlayer">
			<div class="missing">
				<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
					<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
				</a>
			</div>
		</div>
	</body>
</html>

apparently the problem presents when having DOCTYPE and HTML declarations… :face_with_spiral_eyes: