/    Sign up×
Community /Pin to ProfileBookmark

Window opener

Hello,

I am new to Javascript and am trying out window communication with a popup.
In the main window it opens up a popup window with a button click. The popup window is trying to grab text from the main window and put it in it’s (the popup’s) window. I guess it needs a test to see if the window is ready??

Here’s the code:

<html>
<head>
<title>Main</title>
</head>
<body>
<script language=”JavaScript” type=”text/javascript”>

var newWindow;
function butOpenWindow()
{
newWindow = window.open(‘newindow.html’,’DS_window’,’width=300,height=300,resizable=yes,scrollbars=yes’);
}

</script>
<form name=form1>
<br>
Main window<br>
Input text<br>
<input type=”text” name=”text1″>
<br><br>
<input type=”button” value=”Open Popup” name=butOpenWin
onclick=”butOpenWindow()”> <br><br>
</form>
</body>
</html>

The Popup:
<html>
<head>
<title>Popup Window/title>
</head>
<body>
<script language=”JavaScript” type=”text/javascript”>

document.form2.text2.value = window.opener.document.form1.text1.value;

</script
<form name=form2>
<br>
Main Window text:<br>
<input type=”text” name=text2>
<br>
</form>
</body>
</html>

Thank You,

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 13.2010 — &lt;script type="text/javascript"&gt;
window.onload=function() {
document.form2.text2.value = window.opener.document.form1.text1.value;
};
&lt;/script
Copy linkTweet thisAlerts:
@coolechoauthorApr 13.2010 — Thanks Fang,

I tried it but the popup still does not grab what's in the main window's text1 box.

Regards
×

Success!

Help @coolecho spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...