How to call parent window function from child window jquery?

前端 未结 3 1077
青春惊慌失措
青春惊慌失措 2020-12-03 16:54

i just need to call function in parent window while user is focusing on child window. i have this code in my parent window,

 
    

        
3条回答
  •  伪装坚强ぢ
    2020-12-03 17:52

    Try something like below:

    parent.html

     
        
        
         
            Click here to open the child window
         
    
    

    child.html

    
        
            
            
        
         
            

    This is Child window

    You should not do this on the parent, otherwise opener.CallParent() will not work, doing window.CallParent makes CallParent available as window scope:

    function CallParent() {
      alert(" Parent window Alert");
    }
    

    And then you can simply call opener.CallParent(); not window.opener.CallParent();.

提交回复
热议问题