Forum Moderators: open

Message Too Old, No Replies

Access Is denied- Passing data from popup window to the parent window

         

mkohan

6:59 pm on Mar 1, 2007 (gmt 0)

10+ Year Member



Hi,
I want to pass data from popup window to the parent window.
every time I tried i got "Access is denied"
parenet window has a link that pops up a child window. In child window(pop up) a jsp program runs which has three steps to complete so all inside child window( every time a submit).
my short codes:

<!-- Parent Window -->
<form name="addressChanges">
<A href="" onClick="window.open('/help.jsp','help','width=550,height=550,screenX=50,screenY=0,top=75,left=310,menubar=0,status=0,scrollbars=0,resizable=1,toolbar=0,location=0,directories=0');return false">
</a> click</td></tr>
<tr>
<td width="150" height="23" align="right" class="normal">Street1: </td><td width="150" height="23"><input type="text" name="home" value="" class="data"></td></tr>
</form>

<!-- Child window -->

<a href="#" onClick="parent.window.opener.document.addressChanges.home.value='Smith'">Home</a>

-----
I tried diffrent ways but I got "Access is denied"
Thanks,

MK

rocknbil

11:56 pm on Mar 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard mkohan, two comments,

<a href="#" onClick="parent.window.opener.document.addressChanges.home.value='Smith'">Home</a>

Did you try just
window.opener.document.addressChanges.home.value='Smith'

without parent? Being a pop up, the window has no parent. Only an opener.

Second, unrelated but important, three things:

<A href="/help.jsp" onClick="window.open('/help.jsp','help','width=550,height=550,screenX=50,screenY=0,top=75,resizable');return false">

Note my changes. return false will stop the document from executing the link as it normally would, so you want /help.jsp in the link. This way if Javascript is disabled, they still get to the content.

You don't need to specify all available parameters or set a value. Therefore, as shown will only set witdh, height, resizable, etc. I would still recommend scrollbars, you never know your user's environment.

Last, you should generate unique id's for the window name, 'help'. Take this scenario, a common one:

User clicks a help link. While that info is valuable, it doesn't answer the question. User clicks back in the main window without closing popup, selects a different link . . . and nothing happens. Or appears not to. Conclusion: "this site is broken."

What has actually happened is the second link has loaded it's content in the window 'help', which is already open, and the user is unaware of it because the'yve clicked in the main window and covered up your popup. Always specify a unique is for the window name. This will insure that a new window indeed pops up when clicked.