how to call a javascript function in the top frame?
        Posted  
        
            by Rory
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Rory
        
        
        
        Published on 2010-06-18T11:23:29Z
        Indexed on 
            2010/06/18
            11:33 UTC
        
        
        Read the original article
        Hit count: 256
        
JavaScript
|frames
This seems really simple, but how do I call a javascript function that's defined in the top-level html, from a child frame?
top html doc
 - 1st level frame
    - 2nd level frame
my top html doc has a function called testFn(). In the 2nd level frame I have a button with onclick="top.testFn();" but this doesn't call the testFn(). In Firebug if I use a watch to execute top.testFn(); it says TypeError: testFn() is not a function. 
Should this all just work - in which case it's a problem with my documents, or is there some other way to call functions in the top-level window?
© Stack Overflow or respective owner