[thelist] alert() and that type of effect on a function (read for explanation)

Tom Dell'Aringa pixelmech at yahoo.com
Wed Jul 3 13:16:01 CDT 2002


Sorry about the goofy subject title, but this is hard to explain and
totally confounding me.

This is a semi-complex thing so I will try and simplify it. I have a
frameset of 3 rows. This is nested in other framesets and there is a
lot of talking back and forth between frames, just fyi.

The top frame set is the control area for the bottom 2 rows, via a
dropdown menu. So you have this:

+---------------------+
+ dropdown control    +
+---------------------+
+                     +
+  top stuff          +
+                     +
+---------------------+
+                     +
+  bottom stuff       +
+---------------------+

The control gives you 3 options:
1) show both top and bottom stuff
2) show top stuff
3) show bottom stuff

If you choose only top stuff, there are DIVs inside there that get
resized based on the height of the browser window, so the controls
for the top stuff window are not 'floating' in the middle of the
frame, but are on the bottom. Phew!

This works by calling a function that sends the selectedIndex of the
drop down to a swich case method like this:

---
case 0:
document.getElementById("toggleView").selectedIndex = 0;
parent.document.body.rows = "46, 300, *";
document.cookie = "view=both";
break;

and so on.
---

When this happens, the frame has an onResize event triggered that
fires off the function to resize the stuff INSIDE the top frame. It
all works fine by itself. Until they wanted the setting to be
remembered via a cookie. So I set the cookie. Finally - here is the
problem!

So the cookie saves "view=both" and reads it back when you come back
to this section, and based on that value of view = sets the frame
configuration to what it was before - so if you had it set to top
stuff only it sets it to that again.

Again, I am using switch case:

----
switch(curView)
 {
  case "both":
  toggleFrame(0);
  break;
----

where curView is the saved value of the cookie -- so '0' is the
topstuff only. It calls toggleFrame(), which is the function above to
trigger the whole thing off.

Well, when this happens, the stuff INSIDE the topstuff DOES NOT
resize like it does when you normally do it. There were some frame
issues, so I pulled the code that resizes the stuff inside right into
my function that retrieves the cookie and sets the view to the saved
state. Again, it DOES NOT work -- even thought its the EXACT same
code that works when you trigger it the other way.

I thought maybe you couldn't call functions inside a switch or
something. Then I decided to use an alert to find out what the row
values were - maybe the stuff inside THOUGHT it was in the right
place.

That was the problem - and here is where the funny thing is - once I
put that alert in, to fire off the row values -- the function WORKED.
The stuff inside resized like it should have.

This blows me away. What does an alert() do to the flow of the
execution that allows this? Basically it gives me the values of "46,
*, 0" because of course, the bottom frame should be hidden. That is
what the alert returns.

But if I check simply the height of the top frame, I get 300 - which
is not correct -- it should be set to "*" which is like 474 pixels.
But firing off that alert "fixes" it!

I apologize for the long post, not sure if I have given enough or too
little info, and not sure if you can help. If you want to see the
code I can post it but it would be a lot.

Obviously I can't leave the alert in..I tried setting a phony
variable to the rows, that didn't work either..

Tom



=====
var me = tom.pixelmech.webDeveloper();
http://www.pixelmech.com/

__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com



More information about the thelist mailing list