Patriotec
Patriotec

Reputation: 399

Embed Flash using SWFObject with Strict Doctype

Having a problem embedding a flash chatroom under a doctype equaling strict using the SWFObject

Without the doctype of strict i lose the margin:auto usage under IE. Using the doctype of strict the flash chat room doesnt load properly at all. I read the swfobject embedding techniques for doctype of strict but can not actually get it. This is what i have below, but it squishes the flash together at top instead of expanding it at 100% in height

<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Flashchat</title>
<link href="sitecss.asp" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="flash_swf">
<script type="text/javascript">
//<![CDATA[
var so = new SWFObject("swf.swf", "videochat", "100%", "100%", "8", "#FFFFFF");
so.addVariable("rootPath", "http://www.domain.com/flashchat/");
so.addVariable("roomId", "Room");
so.addVariable("app", "chat/videochat.swf");
so.addVariable("uid", "somename");
so.addVariable("skin", "Lead Grey");
so.addParam("wmode", "opaque");
so.write("flash_chat_swf");
// ]]>
</script>
</div>

</body>
</html>

OK, i used javascript to resize the flash on page load

<script type="text/javascript"> 
function resize(){  
var frame = document.getElementById("flash_swf");  
var htmlheight = document.body.parentNode.scrollHeight;  
var windowheight = window.innerHeight;  
if ( htmlheight < windowheight ) { document.body.style.height = windowheight + "px"; frame.style.height = windowheight + "px"; }  
else { document.body.style.height = htmlheight + "px"; frame.style.height = htmlheight + "px"; }  
}
</script>

<body onload="resize()" onresize="resize()">

But, I have a menu on top that's 40px in height. So I had to set a margin for the DIV margin:40px 0 0 0;. Now the flash is being cutoff 40px too short. How do I set the htmlheight and windowheight within the javascript so its 40 pixels less (-40px) ?

Upvotes: 1

Views: 806

Answers (1)

Erwan
Erwan

Reputation: 398

I don't think that the doc type has anything to do with your issue! Are you using the last version of SWFObject (I think that the embed method you're using is old...) ?

Anyway, the line

so.write("flash_chat_swf");

should be replaced by

so.write("flash_swf"); // corresponds to the div id the flash should be written in

And please insert the java script code outside of the div.

Instead of manually resizing the window, you should implement this script: http://swffit.millermedeiros.com/ This works very well with swfobject.

Hope this helps!

Upvotes: 1

Related Questions