Jump to content
kv79

Java Script Avail.width

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>

Share this post


Link to post
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';

Share this post


Link to post
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;

Share this post


Link to post
Share on other sites

Are you sure you want the screen width? That tells you nothing about the window width.

Share this post


Link to post
Share on other sites

expain plz, how do you mean its nothing telling me ?You can show your window screen with width

alert('screen.availWidth);

but can't pass that that value to variable :) dunno why :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...