IE5.0 and frames

Is it possible to call a user-defined javascript function in another frame in IE5.0?

I try something like this but I get the error that the object method is not supported:
window.frames['myframe'].myfunction(myVar);
LVL 5
Darth_helgeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

knightEknightCommented:
try this:

top.frames['myframe'].myfunction(myVar);
knightEknightCommented:
... but it will not work if the page in the other frame is served from a different domain.
Darth_helgeAuthor Commented:
well, I didn't get any errors on that one, but THAT didn't work in IE6.0!?

Isn't there a statement that works for all browsers?? FF,IE5.0-->6.0

-Mr.Optimistic
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

knightEknightCommented:
hmm, that is odd.  Can you show us the actual code?
Also, are both frame pages served from the same domain name?
ZvonkoSystems architectCommented:
You can call it eithe way:
window.frames['myframe'].myfunction(myVar);
parent.frames['myframe'].myfunction(myVar);
top.frames['myframe'].myfunction(myVar);
window.frames.myframe.myfunction(myVar);
parent.frames.myframe.myfunction(myVar);
top.frames.myframe.myfunction(myVar);

But the var myVar has to be defined in the window context where the upper call statement is evaluated. Otherwise is myVar undefined.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
knightEknightCommented:
... unless perhaps you are using frames within frames.  Show us also your frame code.
jweston1Commented:
Is the frame named "myframe" in the frameset? An index into the frameset could also be used.
Darth_helgeAuthor Commented:
this a javascript function in the main page:
            function SyncTree(id)
                  {
                        if (window.frames['fraTree'].document.readyState=="complete")
                              {
                              window.frames['fraTree'].syncByValue(id);
                              }
                  }      

this is where the iFrame is defined in the page:
<iframe id="IfraTree" src="treePreview.aspx" name="fraTree" runat="server" height="100%" style="WIDTH:270px" frameborder="no" scrolling="no"></iframe>

and this is the javascript syncByValue function (but this is not the problem I think. I tried creating a simple 'test' with an 'alert();' but couldn't call that one either):
function syncByValue(val)
      {
      var i;
      var n;
      
      if (document.readyState=="complete")
            {
            for (i=0; i<t.AllNodes.length; i++)
                  {
                  if (val == t.AllNodes[i].Value)
                        {
                        n=t.AllNodes[i];
                        }
                  }
            t.UnSelectAllNodes();
            n.Highlight();
            EXPANDNODEPARENTSBYNODE(n)
            
             var selectedNode = t.SelectedNode;
                  if (selectedNode != null) {  
                        var sn = document.getElementById(selectedNode.ID);
                        if (sn != null)      {
                              sn.scrollIntoView();                        
                              }
                  }
            
            }
      }

Darth_helgeAuthor Commented:
ok, maybe i screwed up. here is the FULL version of the function: maybe it's the other lines:

            function SyncTree(id)
                  {
                                    
                  if ((id!=0)&&(id!=undefined))
                        {
                        if (window.frames['fraTree'].document.readyState=="complete")
                              {
                              window.frames['fraTree'].syncByValue(id);
                              }
                        }
                  }      
knightEknightCommented:
a couple of things to try ... in treePreview.aspx, do this:

<BODY onload="self.syncByValue=syncByValue;">


If that doesn't work then try accessing your frame by the id instead:

if ( top.document.getElementById('IfraTree').document.readyState=="complete" )
    {
       top.document.getElementById('IfraTree').syncByValue(id);
    }
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.