Showing posts with label js popup window. Show all posts
Showing posts with label js popup window. Show all posts

Sunday, November 30, 2014

JavaScript How to Interact with Parent window from child window

javascript


parent.html

[sourcecode language="html"]
<html>
<head>
<script >
// assigning new property with function so child window can point it
document.functionToBeCalledFromChildWindow = function (param){
  alert(param);
}
 
</script>
</head>
<body>
 <div id="response"></div>
<button onClick="window.open('child.html', '_blank', 'width=500,height=500')">Open window</button>
</body>
</html>
[/sourcecode]

child.html

[sourcecode language="html"]
<html>
<head>  
</head>
<body>
 <script >
   window.onload = after;
   function after(evt)
   {
       
   }

//Here we call function "functionToBeCalledFromChildWindow" in parent window.
//window.opener.document.functionToBeCalledFromChildWindow('Mom, U there?');

//Here we access DOM in parent.
 window.opener.document.getElementById("response").innerHTML = "Success";
 window.close();
 opener.window.focus()
</script>

Hi I am the only child here.
 
</body>
</html>
[/sourcecode]

How to enable CORS in Laravel 5

https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...