Home  >  Article  >  Web Front-end  >  How to output content to the parent window after JavaScript pops up a new window_javascript skills

How to output content to the parent window after JavaScript pops up a new window_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:05:421277browse

The example in this article describes the method of outputting content to the parent window after JavaScript pops up a new window. Share it with everyone for your reference. The details are as follows:

The following JS code demonstrates how to open a pop-up window through the window.open method, and then output information to the parent window through the handle of the pop-up window

<!DOCTYPE html>
<html>
<head>
<script>
function openWin()
{
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>This is 'myWindow'</p>");
myWindow.focus();
myWindow.opener.document.write("<p>This is the source window!</p>");
}
</script>
</head>
<body>
<input type="button" value="Open 'myWindow'" onclick="openWin()" />
</body>
</html>

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn