Click here to Skip to main content
13,141,637 members (58,873 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I have a code that opens a dialogbox to browse for folder path using javascript This code is called from a Master content page ASP.Net. The problem is from the child node I used window.opener to return the value to a text box in the parent page..but it does not return the value and it does not close the is my code
function SelectAndClose() {
    txtValue = document.getElementById('<%= _browseTextBox%>').value;
    window.opener.document.BodyContent.getElementById('txtRawAnl').innerText = txtValue;

I am calling this from a JS file and I referenced the JS file on the head tag of the child page.

Posted 9-Oct-12 10:40am
Updated 9-Oct-12 10:47am
Zoltán Zörgő 9-Oct-12 16:43pm
The child window url is from the same domain? How exactly is the child window opened? The alert you added is showing?
Franco Cipriano 10-Oct-12 9:43am
How do I know if the URL is from the same domain? the child window is opened by calling from the parent page..and the alert does not show up
Zoltán Zörgő 10-Oct-12 12:37pm
Well, they are on the same domain if the fqdn part of their url is the same, the rest does not matter. Ex: and are in the same domain.
Try to put only an alert(window.opener); in the function - it should show an alert regardless of it can or can not access the opener window content itself. And make sure, that there is no Javascript syntactic error on the page.
Franco Cipriano 10-Oct-12 13:05pm
i got another example from this link

I revised it and this is how it looked like on my code:


function openChildWindow(tagetControlId) {

var s = "BrowseDirectory.aspx?id=" +tagetControlId;,'', 'width=400,height=600,status=no,toolbar=yes,menubar=no,location=no');

return false;


function Done() {
p = window.opener.document; //parent window
target = p.getElementById(GetElementFromQuery(, 'id'));
alert('1 ' + target);
target.value = document.getElementById('browseTextBox').value;
alert('2 ' + target.value);
function GetElementFromQuery(url, name) {
x = url.split("&"); for (i = 0; i < x.length; i++) {
if (x[i].split("=")[0] == name) {
return x[i].split("=")[1];
return "";

I am getting a null on target..but on the example it shows an object..

I tried the example and it worked..but it did not work on my web app..I am calling the child page from a master content page..the examples are 2 not master content pages..does it matter?

Franco Cipriano 11-Oct-12 10:17am
Just an update on my problem..i tried to replicate this on an ordinary web form and not a master content page and the javascript not sure why it does not work with master content pages

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100