0

I have a line like this:

<EMBED SRC="ObtainingAndBuilding_Linux.swf" WIDTH=200 HEIGHT=300</EMBED>

that I want to replace 200 and 300 by the browser window width and height.

I found some code like this which correctly gets and displays the width and height:

<HTML>
<head>
<script>
function showWH(){
if (document.all){
cW=document.body.offsetWidth
cH=document.body.offsetHeight
window.resizeTo(500,500)
barsW=500-document.body.offsetWidth
barsH=500-document.body.offsetHeight
wW=barsW+cW
wH=barsH+cH
window.resizeTo(wW,wH)
}
else
{
wW=window.outerWidth
wH=window.outerHeight
}
alert(wW+' '+wH)
}
</script>
</head>

<BODY onload="showWH()">
<EMBED SRC="ObtainingAndBuilding_Linux.swf" WIDTH=200 HEIGHT=300 quality=low loop=false TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</EMBED>

</BODY></HTML>

However, when I replace the hard coded with and height with:

WIDTH=wW HEIGHT=wH

The object gets very small (i.e. it is not any where near the window size.) Is there some syntax I am missing to get the value of these variables? (like a "${wH}" or something?)

Thanks,

David

2
Contributors
3
Replies
6
Views
7 Years
Discussion Span
Last Post by daviddoria
0

When you say you are replacing the hardcoded values do you mean you are grabbing the embed element and dynamically setting the height and width or are you trying to use the js var's wW and wH when the embed element is initially drawn? The difference between the two is that the var's wW and wH aren't being calculated until after the embed element is already drawn. You should give the embed element an id and then use

var embedEl = document.getElementById("embedId");
embedEl.setAttribute("HEIGHT",wH);
embedEl.setAttribute("WIDTH",wW);

In the place where you are doing the alert() in your showWH function.

0

I thought I had the idea, but it doesn't seem to be working:

<HTML>
<head>
<script>
function showWH(){
cW=document.body.offsetWidth
cH=document.body.offsetHeight
window.resizeTo(500,500)
barsW=500-document.body.offsetWidth
barsH=500-document.body.offsetHeight
wW=barsW+cW
wH=barsH+cH
window.resizeTo(wW,wH)
var embedEl = document.getElementById("embedId");
embedEl.setAttribute("HEIGHT",wH);
embedEl.setAttribute("WIDTH",wW);
}
</script>
</head>
<BODY>
<center>
<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0">
<PARAM NAME=movie VALUE="ObtainingAndBuilding_Linux.swf">
<PARAM NAME=play VALUE=true>
<PARAM NAME=loop VALUE=false>
<PARAM NAME=quality VALUE=low>
<EMBED id="embedId" SRC="ObtainingAndBuilding_Linux.swf" quality=low loop=false TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</EMBED>
</OBJECT>
</center>
</BODY></HTML>

Any thoughts?

Thanks!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.