Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

centering flash via script

Status
Not open for further replies.

idaryl

Technical User
Nov 10, 2001
156
US
Hello all,

I have another one here... I have this code but it appears to set the file to the default/left on a page - but the client wants it centered - I tried adding another part (document.write('<div align="center">'); at the begiining and document.write('</div">'); at the end of the function ) - i also tried to add it to the script in other places as well - but it did not work - can this be done?

here is the code
Code:
var arr = new Array();
var arr1 = new Array();
var sec  = null;
var secstr = '';
str = location.search.substring(1, location.search.length);
arr = str.split("&");
for (i=0;i<arr.length;i++) {
        temp = arr[i];
        arr1 = temp.split("=");


        if (arr1[0] == "section") {
                sec = arr1[1];
        }

	if (sec != null) {
		secstr = '?section='+sec;
	}

}
function writeflash () {
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="[URL unfurl="true"]http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"[/URL] width="760" height="560" id="index" align="middle"></div>');
document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name="movie" value="index.swf'+secstr+'" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="bgcolor" value="#000000" />');
document.write('<embed src="index.swf'+secstr+'" quality="high" bgcolor="#000000" width="760" height="560" name="index" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] />');
document.write('</object>');

}

idaryl
idface.gif
 
Code:
function writeflash () {
document.write('<div align=center>');
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="[URL unfurl="true"]http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"[/URL] width="760" height="560" id="index" align="middle"></div>');
document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name="movie" value="index.swf'+secstr+'" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="bgcolor" value="#000000" />');
document.write('<embed src="index.swf'+secstr+'" quality="high" bgcolor="#000000" width="760" height="560" name="index" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] />');
document.write('</object>');
document.write('</div>'>;

}

That should do it for you.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
If pixl8r's suggestion didn't work then you've got something else going on that we can't see. Can you provide a link to the page?

There's always a better way. The fun is trying to find it!
 
Yes please or more complete coding of the page.

Wow JT that almost looked like you knew what you were doing!
 
OK here it is
Code:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Brent Lindstrom</title>
<script language="JavaScript">
var arr = new Array();
var arr1 = new Array();
var sec  = null;
var secstr = '';
str = location.search.substring(1, location.search.length);
arr = str.split("&");
for (i=0;i<arr.length;i++) {
        temp = arr[i];
        arr1 = temp.split("=");


        if (arr1[0] == "section") {
                sec = arr1[1];
        }

	if (sec != null) {
		secstr = '?section='+sec;
	}

}
function writeflash () {
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="[URL unfurl="true"]http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"[/URL] width="760" height="560" id="index" align="middle"></div>');
document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name="movie" value="start.swf'+secstr+'" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="bgcolor" value="#000000" />');
document.write('<embed src="start.swf'+secstr+'" quality="high" bgcolor="#000000" width="760" height="560" name="index" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] />');
document.write('</object>');

}
</script>


<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
<div align="center">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td height="187"> 
        <div align="center"><script language="JavaScript">writeflash();</script></div>
      </td>
    </tr>
  </table>
</div>
</html>

idaryl
idface.gif
 
If you insist on using a div inside of a table inside of a div, then try changing this:

<td height="187">
<div align="center"><script language="JavaScript">writeflash();</script></div>
</td>

to this:

<td height="187" align="center">
<div align="center"><script language="JavaScript">writeflash();</script></div>
</td>

But you don't need the table, or the div inside of the table.

There's always a better way. The fun is trying to find it!
 
You could also simplify your HTML further.

Code:
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td height="187" align=center> 
         <script language="JavaScript">writeflash();</script>      </td>
    </tr>
  </table>

</html>

However I think the best solution is to write the whole page with your javascript:

Code:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Brent Lindstrom</title>
<script language="JavaScript">
var arr = new Array();
var arr1 = new Array();
var sec  = null;
var secstr = '';
str = location.search.substring(1, location.search.length);
arr = str.split("&");
for (i=0;i<arr.length;i++) {
        temp = arr[i];
        arr1 = temp.split("=");


        if (arr1[0] == "section") {
                sec = arr1[1];
        }

    if (sec != null) {
        secstr = '?section='+sec;
    }

}

function writeflash () {
document.write('<body marginwidth=0 marginheight=0 topmargin=0>');
document.write('<div align=center>'); 
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="[URL unfurl="true"]http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"[/URL] width="760" height="560" id="index" align="middle"></div>');
document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name="movie" value="start.swf'+secstr+'" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="bgcolor" value="#000000" />');
document.write('<embed src="start.swf'+secstr+'" quality="high" bgcolor="#000000" width="760" height="560" name="index" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] />');
document.write('</object>');
document.write('</div>');
document.write('</body>');
document.write('</html>');

}

window.onload = writeflash;

</script>

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top