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,402
  • 8
  • 50
  • 61
DONG
  • 59
  • 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,890
  • 1
  • 17
  • 32
-1

Try this:

window.opener.functionName()
Mark
  • 2,380
  • 11
  • 29
  • 49
K.K.Agarwal
  • 846
  • 5
  • 10