Thanks for the working example Christian!  I just knocked mine out off
the top of my head and since I didn't see any more posts, I assumed
the original poster figured it out.  A caveat - your solution only
works if there are no other iframes on the page.  To get around it, on
the framing page you can use
frames["GB_frame"].frames[0].document.getElementById(...

or in the greybox you can use
top.frames["GB_frame"].frames[0].document.getElementById(...



I hate timers - too iffy!  To overcome the race condition that
Christian mentions, I would have both the main page and the greybox
set variables on the main page when they have loaded:
Main Page---------------------------------
...
var mainPageLoaded =false;
var greyBoxLoaded=false;
...
<body onload='mainPageLoaded =true'>

Greybox---------------------------------
<body onload='top.greyBoxLoaded=true'>

I would also add a function to the main page that would check if both
variables were true, and if so to run the focusing code:
Main Page---------------------------------
...
function focusGBElement(elementId) {
  if(mainPageLoaded && greyBoxLoaded) {
    try { frames["GB_frame"].frames[0].document.getElementById
(elementId); }
    catch(e) { alert("Error! " +e.message); }
  }
}
...



To make certain that it gets run, add the function call to both
onloads:
Main Page---------------------------------
<body onload='mainPageLoaded =true'; if(mainPageLoaded &&
greyBoxLoaded) { focusGBElement("myinput"); }'>

Greybox---------------------------------
<body onload='top.greyBoxLoaded=true; if(top.mainPageLoaded &&
top.greyBoxLoaded) { top.focusGBElement("myinput"); }'>



FYI, I use greybox for all kinds of forms and so forth on my company's
site - no image popups at all :)

Hope that helps things out a little!

Tyler Style
http://www.nirdvana.com


On Dec 10, 2:10 pm, "[email protected]"
<[email protected]> wrote:
> I had exactly the same issue. Are we the only ones using Greybox for
> more than fancy image popups? Whatever... The short answer is:
>
> top.frames[0].frames[0].document.getElementById
> ('idofyourformelement').focus()
>
> called from within the Greybox, although that should not matter.
> Assuming you have only one main page and call Greybox from that.
>
> With top.frames[0] (of type window) you have access to the Greybox-
> Loader (loader_frame.html) that in turn loads the actual page within
> an iframe. Hence the .frames[0] - thing. From that, you can apply the
> usual stuff to get things working. Unfortunately the iframe for
> loading the page does not have a name; otherwise one could use that.
>
> The problem is, if you really want to focus right after loading, it is
> next to impossible due to crazy race conditions. I tried to add the
> code directly after Greybox gets created in loader_frame.html - it did
> not work. Even with the onload event in the page that the Greybox
> load, did not solve the problem. Therefore I can only recommend using
> something like:
>
> window.onload=function(){
>
>           window.setTimeout("top.window.frames[0].frames
> [0].document.getElementById('inputstart').focus();",1500);
>
>         }
>
> In the page that the Greybox loads...
>
> Christian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"GreyBox" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/greybox?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to