0

For exemple, in the parent page

<script src="js/test.js"></script>

and then we use window.open to open page 2, so in page 2, how do we use window.opener for calling functions in the test.js?

devnull69
  • 16,004
  • 4
  • 45
  • 57
DONG
  • 49
  • 1
  • 10
  • `window.opener.whateverfunction()`? – putvande Jun 16 '14 at 12:20
  • Duplicate? http://stackoverflow.com/questions/10591050/javascript-window-opener-call-parent-function – bloodyKnuckles Jun 16 '14 at 12:21
  • @putvande I used 'try{ if(parent.window.opener != null && !parent.window.opener.closed) { parent.window.opener.testCall(); } }catch(e){ alert(e.description);' But get a undefined error. It maybe works only for the functions defined directely in the parent page not js/test.js ??? – DONG Jun 16 '14 at 12:24
  • Can you create a Fiddle and reproduce your problem. – putvande Jun 16 '14 at 12:26

2 Answers2

0

window.opener.functionOnParentPage();

myfunkyside
  • 3,810
  • 1
  • 16
  • 31
-1

Try this:

window.opener.functionName()
Mark
  • 2,372
  • 11
  • 28
  • 48
K.K.Agarwal
  • 846
  • 5
  • 10