Div Tag Centering

admin

Administrator
Staff member
Does anyone know how to use a div tag to pop open a webpage so that's centered within the browser? I'm specifically trying to center a flash movie within a browser.<!--content-->I'm not positive but I think with a <div> you can only align horizontally. If you want to center something put it in a table.<br />
<br />
I hope this helps!!<br />
SirWeb<!--content-->I am not sure what you are asking . . . <br />
<br />
Are you trying to center a flash movie in the middle of a page?<br />
<br />
Or are you trying to open a popup window containing a flash movie that is centered in the middle of the page?<br />
<br />
-beth<!--content-->this (<!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?s=&threadid=7688&highlight=popup">http://www.htmlforums.com/showthread.ph ... ight=popup</a><!-- m -->) might help!<br />
<br />
let me know if it works for you!<br />
chris<pixelmonkey>:monkey:<!--content--><html><br />
<head><br />
<title>untitled</title><br />
<style type="text/css"><br />
<br />
#flashBox {<br />
position:absolute;<br />
border:5px #fbb917 inset;<br />
visibility:hidden;<br />
}<br />
<br />
</style><br />
<script type="text/javascript" language="JavaScript"><br />
<br />
function getElement(id) {<br />
return document.all ? document.all(id) :<br />
document.getElementById ? document.getElementById(id) :<br />
document.layers ? document.layers[id] : <br />
null;<br />
}<br />
<br />
function getClientWidth() {<br />
if (window.innerWidth) return innerWidth;<br />
if (document.body) return document.body.clientWidth;<br />
}<br />
<br />
function getClientHeight() {<br />
if (window.innerHeight) return innerHeight;<br />
if (document.body) return document.body.clientHeight;<br />
}<br />
<br />
function show(el) {<br />
if (el.style) el.style.visibility = 'visible';<br />
else if (el.visibility) el.visibility = 'show';<br />
}<br />
<br />
function centerBox(box_id, Xoffset, Yoffset) {<br />
Xoffset = Xoffset ? Xoffset : 0;<br />
Yoffset = Yoffset ? Yoffset : 0;<br />
var el = getElement(box_id);<br />
if (!el) return;<br />
if (!document.layers) {<br />
el.style.left = (getClientWidth()/2 - el.offsetWidth/2) + Xoffset;<br />
el.style.top = (getClientHeight()/2 - el.offsetHeight/2) + Yoffset;<br />
} else {<br />
el.moveTo((getClientWidth()/2 - el.clip.width/2) + Xoffset, <br />
(getClientHeight()/2 - el.clip.height/2) + Yoffset);<br />
}<br />
show(el);<br />
}<br />
<br />
window.onload = function() {centerBox('flashBox')}<br />
<br />
</script><br />
</head><br />
<body bgcolor="#c35617"><br />
<br />
<div id="flashBox"><br />
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://Download <!--more-->.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="180" height="320"><param name=movie value="http://www.flashkit.com/tutorials/Actionscripting/Expert/Building-Morten_B-529/building_a_tsunami.swf"><param name=quality value=high><embed src=http://www.htmlforums.com/archive/index.php/"http://www.flashkit.com/tutorials/Actionscripting/Expert/Building-Morten_B-529/building_a_tsunami.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/Download <!--more-->/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="180" height="320"></embed></object><br />
</div><br />
<br />
</body><br />
</html><!--content-->
 
Back
Top