How to get the value from child window to parent across all major browsers?

I am trying to get the selected value from a child window to parent and it works in Firefox but not in Chrome. I need to test this feature across all major browsers viz. Firefox, Chrome, Safari, Opera and IE. Please help

Is there any jQuery equivalent for this feature which will work across all major browsers?

Code for parent window
====================
<html>
<head><title>User Provisioning</title></head>
<body>
<form name="mgr">
<label>Reporting Manager</label>
<input type="text" name="manager" id="manager"></input>
<button name="getManager" onclick="window.open('managerDetails.html', 'managerConsole', 'width=300,height=300')">getManager</button>
</form>
</body>
</html>

Code for child window
==================
<html>
<body>
<h1>People Manager</h1>
<form name="peoplemanager">
<input type="radio" name="manager" value="Thomas (100001)" />Thomas<br>
<input type="radio" name="manager" value="Ambrose (100002)" />Ambrose<br>
<input type="radio" name="manager" value="Richards (100003)" />Richards<br>
<input type="radio" name="manager" value="Helen (100004)" />Helen<br>
<input type="radio" name="manager" value="Robert (100005)" />Robert<br>
<input type="button" id="getManager" value="getManager"></button>
</form>
<script>
    var mgr = document.getElementById("getManager");
    mgr.onclick = function() {
    var val = window.peoplemanager.manager.value;
    var txt = window.opener.document.getElementById("manager");
    txt.value = val;
    window.close();
    }
</script>
</body>
</html>
ShajiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
I tested your code in Chrome and it worked fine.  Other than script runtime errors, the only thing that occurs to me is that the window.close() may be firing too soon.  Try:
<script>
    var mgr = document.getElementById("getManager");
    mgr.onclick = function() {
    var val = window.peoplemanager.manager.value;
    var txt = window.opener.document.getElementById("manager");
    txt.value = val;

   //notice that there are no parenthesis between "close" and the comma
   setTimeout(  window.close, 100 );
    }
</script>

Open in new window

0
ShajiAuthor Commented:
hielo, I am using Windows 8.1 and in Firefox it works just fine and in other browsers it is not working.

In Safari and IE, it is giving 'undefined' value as soon as the window closes
In Opera and Chrome, it is not even closing the window and nothing shows up in the text field (in the parent window)

I am using the following browser versions on Windows 8.1, 64 bit machine

Chrome - Version 45.0.2454.37 beta-m (64-bit)
Firefox - 410b2
IE - 11
Safari - 5.1.7
Opera - 23.0.1522.75

Please help
0
F IgorDeveloperCommented:
In your script, change "window.peoplemanager" with" document.peoplemanager":


<script>
    var mgr = document.getElementById("getManager");
    mgr.onclick = function() {
    var val = document.peoplemanager.manager.value;
    var txt = window.opener.document.getElementById("manager");
    txt.value = val;
    window.close();
    }
</script>

Open in new window


Also you can test the variables before using, calling alert() in some cases:
alert(window.peoplemanager);
alert(window.opener.document.getElementById("manager"));

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShajiAuthor Commented:
Hi fraigor,

This script still does not work in the latest version of Chrome, Safari, Opera and IE in Windows 8.1, but it works in Firefox.

Is there any alternate way (for example, using jQuery) of achieving the same?

Please help.

Thanks in advance.
0
ShajiAuthor Commented:
Greetings,

I used the dialog from JQuery  UI and it seems to do the trick.

https://api.jqueryui.com/dialog/

Thanks hielo and fraigor, for your valuable inputs.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.