Jump to content

Java Script Avail.width


kv79

Recommended Posts

hi allthanks advance this is not working, I really don know why

<script type="text/javascript">var _screen = screen.availWidth;var _width = 495;var _left = ((_screen/2)-_width);document.getElementById('movie').style.left='100px';</script>		<style type="text/css">		div.movie, body, p {			position:absolute;			  		}		p.underline, p , h1 , h2 , u {			position:absolute;			left:5px;			width:100px;			height:100px;			overflow:hidden;		}		p.underline{text-decoration:underline;}		body { margin:0; }		body {background-color:#000;}	</style></head><body>	<div id="movie" class="movie" >		<embed  src="pre_loader.swf" width="991" height="550" />	</div>	</body>

Link to comment
Share on other sites

And I want to replace first one with second but it seems that it's not workingdunno why :)

document.getElementById('movie').style.left='100px';

document.getElementById('movie').style.left=_left + 'px';

Link to comment
Share on other sites

If you were to alert "_left", you'll probably get "NaN" and I'm guessing this would be because you have a typo here:

var _screen = screen.avilWidth;

Link to comment
Share on other sites

Take the quotation mark out of your alert, and it should work.The screen width refers to the total width of the monitor. That is not the same as your window. If the user changes the size of the window, then the window will be smaller than the screen.If you are simply trying to center your movie, there are easier ways that do not require Javascript.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...