Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] Javascript setting frame width

Started by lincsimp Oct 28, 2005 at 8:37 AM 2 replies 1.7k views
Original Post
lincsimp
lincsimp
hey I've got a problem setting the width of a frame ("leftFrame") using &#106avascript. this is my page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<SCRIPT LANGUAGE="&#106avascript"&gt;
window.onload = function(){
    width = document.frames[0].outerWidth;
	//document.getElementByID("fs").setAttribute("cols","1000,*");
    alert('Width = ' + width);
}
//&lt;/SCRIPT&gt;
&lt;/head&gt;
&lt;!-- was 230 --&gt;
&lt;frameset cols="300,*" frameborder="no" border="0" framespacing="0" id="fs"&gt;
  &lt;frame src="left.php" name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame" /&gt;
  &lt;frame src="main.php" name="mainFrame" id="mainFrame" /&gt;
&lt;/frameset&gt;
&lt;noframes&gt;&lt;body&gt;
&lt;/body&gt;
&lt;/noframes&gt;&lt;/html&gt;</pre>

You can see above what I've tried, but I can't seem to get it to work. Can anyone help?


cheers</code></pre>
Wan
Wan
It can be done with something like this IIRC:
parent.document.body.cols = "100,*"
The path depends on where you call the script of course.
lincsimp
lincsimp
Yeah, I used:

document.body.cols = "whatever"

and I got rid of the boy tag at the bottom which, for some reason, sorted the problem....

cheers
lincsimp
lincsimp
Does anyone have any idea how to change the width of a frame dynamically when a page is loading without it going to its original value and then suddenly changing?

cheers

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.