Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2006, 08:49 PM
Authorized User
 
Join Date: Apr 2005
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default JScript and multiple windows

Hey everyone, it is the coder that likes try and code web pages like native windows apps hehe. Anyway, I am working on a fancy little asp.net 2.0 page for laptop chekcouts and I want to be able to say from a popup window transfer data via jscript from the fields in the popup window to the parent window. Basically, here is an example of one way I can do it but instead of me having to do another event on the parent page to read the data, I want the event to run on the popuyp page and transfer the data to the parent. maybe this will make more sense.
Here is one way I know to do it.


var newwindow;
function pageOpenRead()
{
     newwindow = window.open("Popup.htm");
     document.getElementById("txtOutput").value =
     newwindow.document.getElementById("txtInput").valu e;
}

Basically this is how I would do a popup page and I have a reference to the new window but from the new window I do not know the reference back to the parent so i can only really write code fro mthe parent to the popup using the reference while in the popup I do not have one or do not know the reference back to the parent.
 
Old February 11th, 2006, 11:45 AM
Authorized User
 
Join Date: Jan 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to longjava
Default

You can use the 'opener' property of window object to reference back to the parent window.
Here is a example of how the new window(page2.html) getting the data from the parent window(page1.html) and print it out in the text field:

page1.html
----------
<html>
<head>
<script type='text/javascript'>
function openNewWindow()
{
   var newWnd = open( 'page2.html', 'Page2' );
}
</script>
</head>
<body>
<a href='#' onclick='openNewWindow()'>Click here to open new window</a>
<form name='myForm'>
  <input type='hidden' name='color' value='Green'>
</form>
</body>
</html>


page2.html
----------
<html>
<head>
<script type='text/javascript'>
function getDataFromParentWindow()
{
   var colorVal = window.opener.document.myForm.color.value;
   document.myForm.color.value = colorVal;
}
</script>
</head>
<body onload='getDataFromParentWindow()'>
<form name='myForm'>
  Color: <input type='text' name='color' value=''>
</form>
</body>
</html>

I wrote these scripts without testing them so you might find the syntax errors while try them out.
Hope this help.

 
Old February 11th, 2006, 01:28 PM
Authorized User
 
Join Date: Apr 2005
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks alot, that is exactly what I was looking for.
:)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Guidelines needed : multiple windows spacy ASP.NET 1.x and 2.0 Application Design 8 April 21st, 2005 06:02 AM
Multiple windows on click of link spacy Javascript How-To 2 April 11th, 2005 05:57 AM
How to handle multiple IE windows ah_teck81 Classic ASP Professional 8 January 28th, 2005 08:26 PM
How to handle multiple IE windows ah_teck81 Classic ASP Basics 0 January 26th, 2005 05:40 AM
Multiple windows opening Wango Access 1 May 26th, 2004 03:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.