Link to home
Start Free TrialLog in
Avatar of Shaji
Shaji

asked on

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>
SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shaji
Shaji

ASKER

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
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shaji

ASKER

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.
Avatar of Shaji

ASKER

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.