Мне просто нужно вызвать функцию в родительском окне, в то время как пользователь фокусируется на дочернем окне. У меня этот код в моем родительском окне,
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script language="Javascript" type="text/javascript">
function CallParent()
{
alert(" Parent window Alert");
}
</script>
<body>
<a href="javascript:void(0);" NAME="My Window Name" title=" My title here " onClick=window.open("child.html","Ratting","width=550,height=170,0,status=0,");>Click here to open the child window</a>
</body>
</html>
и ниже код находится в моем дочернем окне,
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script language="Javascript" type="text/javascript">
jQuery(document).ready(function(){
window.opener.CallParent();
});
</script>
</head>
<body>
<h2>This is Child window</h2>
</body>
</html>
Итак, в этом случае я предположил, что CallParent()
будет запущен сразу после открытия дочернего окна. но, похоже, он не работает.
может ли кто-нибудь дать мне какие-либо намеки на то, чтобы этот script работал, или лучший способ сделать это.