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

Resizing frameset window

Status
Not open for further replies.

humtake

MIS
Mar 12, 2004
2
0
0
US
im having a dilemma here. i have a site with 4 frames, a top, left, main, and bottom. i now need to add the fuctionality where the site loads up in a 800x600 window when it loads. however, if i try to add the script to the onLoad event, it doesnt work. seems to me its not working because the body tag is placed after the frameset tags.

anyone know of a way to make the window pop up in a 800x600 window that does not involve using the onLoad event? it would seem that javascript would have a way, but i cannot find anything.
 
make your detection BEOFRE uses hits any of the frames.
----Index.html-----------
<body onLoad="
if abc then redirect user to Frameset1.htm
else
redirect user to Frameset2.htm
----------------------------

u would have to make Frameset1 to be "larger" than frameset2. the content pages inside should both be made at 800x600 so they will fit both frameset and you can be reused. Dirty but it works!
now, the question for you is
"based on what do u want to redirect users? Screensize?"
frames are rather nasty and for a resons....but if u need some help post some more...
HTH
All the best!

> need more info?
:: don't click HERE ::
 
I have done this. In my case I write the information I need to a cookie before reloading.

On the frameset page:

Code:
//Check first load window size
function checkSize(){
	//Check for cookie 
	if (getCookie("reload")==null){
		//Initial check of window size. Write to cookie and reload page.
		if (document.body.clientWidth < 970) {
			document.cookie="screensize=small";
			document.cookie="reload=true";
			window.location.reload();
			}
		else{
			document.cookie="screensize=large";
			}
	}
	
}

//Check size after window has been resized
function refreshCheckSize(){
	//Check location of "Main" Window of frameset
	var currentLocation = window.frames["main"].location;
	//Check page size after resize is completed and 
	//write size and location to cookie
	if (document.body.clientWidth < 970) {
		document.cookie="screensize=small";
		document.cookie="reload=yes";
		document.cookie="location="+ currentLocation;
		}
	else{
		document.cookie="screensize=large";
		document.cookie="reload=yes";
		document.cookie="location="+ currentLocation;
		}
	//Reload Window after writing cookie
	setTimeout('window.location.reload()', 50);
}

window.onload = checkSize;
window.onresize = refreshCheckSize;

//Read cookie values
function getCookie(Name) {
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search) 
      if (offset != -1) { // if cookie exists 
         offset += search.length 
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset) 
         // set index of end of cookie value
         if (end == -1) 
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      } 
   }
}

I then evaluate the cookie with ASP:

Code:
<%
screenwidth=Request.Cookies("screensize")

if Request.Cookies("reload") = "yes" then
	mainLocation = Request.Cookies("location")
else
	mainLocation = "default2.asp"
end if
	
if screenwidth = "small" then
	framesize=145
else 
	framesize=130
end if
%>

Then insert the variable into the frameset:

Code:
<frameset rows="<%=framesize%>,*" border="0" frameSpacing="0" frameBorder="0">
		<frame name="head" src="header.asp" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0" noresize>
		<frame name="main" src="<%=mainLocation%>" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0">
	</frameset>

I hope that gives you enough that you can modify it to suit your needs. Obviously this will not work if cookies are blocked. Unless you are working in a fixed environment (which I am) you would also need to detect whether or not cookies are enabled.

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top