0

Actually I am trying to access Javascript function of parent window from child window using window.opener .Everywhere it is working fine But in iPad Chrome it does not work. Can we have a work around for this?It will be great help. Below is the detail description of my code.

I have one file test1.html(parent file)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
    function opentest2() {
        window.open('test2.html', '_blank');
    }
    function parentFunction() {    //This function does not execute.
        alert('called from parent'); 
    }
</script>
</head>     
<body>
<input type="button" value="openanother window" onclick="opentest2()"/>
</body>
</html>

I have another file named as test2.html (child file)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
    function callingchild() {
        alert('hii');
        alert(window.opener);
        window.opener.parentFunction();
    }
</script>
</head>
<body>
<input type="button" value="call parent function" onclick="callingchild()"/>
</body>
</html>

I added some alerts while debugging in iPad chrome.But the thing is that I am unable to execute this parentFunction() function. I also tried with window.parent and window.top but both are not working.

Thanks in advance

Bharat Sewani
  • 628
  • 2
  • 10
  • 18
  • You may look at [this](http://stackoverflow.com/questions/10872609/window-open-in-an-ipad-on-load-of-a-frame-does-not-work), and [this](http://stackoverflow.com/questions/9880316/javascript-window-open-in-safari). – Pavel Adrian Oct 08 '14 at 07:25
  • @PavelAdrian: these links did not help me out. Actually the problem is with `window.opener` not with `window.open`. `window.open` is working fine everywhere. problem is with `window.opener`. – Bharat Sewani Oct 08 '14 at 09:31
  • See this answer http://stackoverflow.com/a/32640630/1571834 – erroric Aug 31 '16 at 19:30

0 Answers0