Sunday, November 30, 2014
JavaScript How to Interact with Parent window from child window
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]
Subscribe to:
Post Comments (Atom)
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...
-
< Requirements Java Development Kit (JDK) NetBeans IDE Apache Axis 2 Apache Tomcat Server Main Topics Setup Development Environ...
-
Download Sourcecode [sourcecode language="csharp"] using System; using System.Collections.Generic; using System.Linq; using System...
No comments:
Post a Comment