Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to rendar data from new window to old window through window.focus() ? Or any other way.

 
Abhra Kar
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a jsp named index.jsp---------
<html>
<head>
<script type="text/javascript">
function myfunc(){
var fname=document.getElementById("fname");
var lname=document.getElementById("lname");
window.open("credential.jsp?fname="+fname.value+"&lname="+lname.value,"mywindow","width=200,height=200");
}
</script>
</head>
<body>

<form name="form1">
First Name:
<input type="text" name="fname" id="fname" />
Last Name:
<input type="text" name="lname" id="lname" />
<input type="button" value="click here" onclick="myfunc()" />
</form>
</body>
</html>


Now flow goes to credential.jsp----------
<%@ page isELIgnored="false" %>
<html>
<head>
<script type="text/javascript">
function myfunc1(){
var origWin = window.opener ;
if (origWin != null) {
origWin.document.body.style.backgroundColor = "#a1b2c3" ;
origWin.focus() ;
}
}
</script>
</head>
<body>
<form>
<input type="text" name="credential" value="${param.fname}" />
<input type="hidden" name="lastname" value="${param.lname}" />
<input type="password" name="password"/>
<input type="submit" value="click it" onclick="myfunc1()" />
</form>
</body>
</html>


From credential.jsp flow is coming back to index.jsp,but I want the data I have filled in input field I will append in index.jsp in a text area .
Please suggest me the way(with window.focus() or without window .focus())
Thanks in advance.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
window.opener is the way to do it. If you debug window.opener is it null? Are you getting errors?

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic