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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Layer = screen.width

Status
Not open for further replies.

caseye

IS-IT--Management
Feb 7, 2002
52
0
0
US
I am looking for a javascript to resize a layer to the width of the displayed area does anyone know where I can get this
 
here's one way, for IE4+ and NS6+...not sure if NS4 can do it.

Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 FINAL//EN&quot;>
<html>
<head>
<title></title>

<script name=&quot;javascript&quot;>
function fitWin(oEl) {
	var ie  = document.all;
	if (document.layers) return false;
	oEl.style.width = ((ie)?document.body.clientWidth:document.width) + &quot;px&quot;;
}
</script>

<style type=&quot;text/css&quot;>
div {
	position:absolute;
	top:100px;
	left:0px;
	border:1px solid #000000;
	text-align:center;
	padding:5px;
}
</style>

<meta name=&quot;author&quot; content=&quot;?&quot;>
<meta name=&quot;keywords&quot; content=&quot;?&quot;>
<meta name=&quot;description&quot; content=&quot;?&quot;>
</head>

<body>
<a href=&quot;#&quot; onclick=&quot;fitWin(div1);return false;&quot;>fitWin();</a>
<div id=&quot;div1&quot; onmousedown=&quot;fitWin(this);&quot;>i am a div</div>
</body>
</html>



======================================================================= ======================================

if (!succeed) try();
-jeff
 
Wouldn't it be easier to just use CSS?

<style type=&quot;text/css&quot;>
#fullscreen {
position: absolute;
left: 0px; top: 0px;
width: 100%; height: 100%;
}
</style>

Then, just assign the ID of the layer to fullscreen.

Hope that helps!

Happy coding! :)
 
yes, but they asked in the js forum! ;-) ======================================

if (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top