Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing value back to opening frame 2

Status
Not open for further replies.

craigward

Programmer
Nov 13, 2007
230
0
0
GB
Hi,
I have some code that forces a value from a popup window back to a field in parent page that the popup was launched form and it works fine. See below

Code:
opener.document.contact._address1.value = “Address 1”

I have set this same code up in a slightly different environment and I am getting the following error. I am guessing the issue is because the opening link to the popup is now within a frameset. The name of the particular frame is mv_top. Here is the error and code that is causing the issue.

Error: opener.mv_top is undefined

Code:
opener.mv_top.contact._address1.value = “Address 1”

Does anyone know how I can get round this?

Many thanks for looking.
 
Each frame still contains a document, so try this:

Code:
opener.mv_top.document.contact._address1.value = 'Address 1';

or, failing that, then this:

Code:
opener.frames['mv_top'].document.contact._address1.value = 'Address 1';

It's been a long while since I've worked with frames, so apologies in advance if neither of these work :)

Dan




Coedit Limited - Delivering standards compliant, accessible web solutions

[blue]@[/blue] Code Couch:
[blue]@[/blue] Twitter:
 
Hi
[ul]
[li][tt]opener[/tt] is the frame containing the document which performed the [tt]window.open()[/tt]. mv_top is not its [tt]iframe[/tt], so it can not see it. Ask the reference from its [highlight][tt]top[/tt][/highlight] instead.[/li]
[li]The [tt]form[/tt] is still inside a [highlight pink][tt]document[/tt][/highlight], not directly in the [tt]window[/tt].[/li]
[/ul]
JavaScript:
opener[highlight][teal].[/teal]top[/highlight][teal].[/teal]mv_top[highlight pink][teal].[/teal]document[/highlight][teal].[/teal]contact[teal].[/teal]_address1[teal].[/teal]value [teal]=[/teal] [green][i]"Address 1"[/i][/green]

Feherke.
 
Thank you both. I have tried both answers but am still getting this error:

Line: 75
Error: Unable to get value of the property 'document': object is null or undefined

Line 75 is

Code:
				opener.top.mv_top.document.contact._address1.value = "address1"

Sorry to be a pain but to have it working fine on a stand alone page not in a frame point the issue to being frae related.

Thanks again
 
How about this?

Code:
opener.top.frames['mv_top'].document.forms['contact'].elements['_address1'].value = 'address1';

Failing that, can you post your frameset code, as well as the code for the form in the "mv_top" frame?

Dan




Coedit Limited - Delivering standards compliant, accessible web solutions

[blue]@[/blue] Code Couch:
[blue]@[/blue] Twitter:
 
Thanks for the reply. I will try this. I would like to send the code but it is set in a CRM system and i can't extract the code that you would need to replicate the environment. I am sure the answer is there with what you have sent i just need to work through it.

Manny thanks for your input.
 
>> i can't extract the code that you would need to replicate the environment.

If you can't view source on the frameset, then copy & paste it, there's something very wrong with your PC :)




Coedit Limited - Delivering standards compliant, accessible web solutions

[blue]@[/blue] Code Couch:
[blue]@[/blue] Twitter:
 
Hi

Just take it step-by-step and see what you get ( and post those values if you not understand them ) :
JavaScript:
[COLOR=darkgoldenrod]alert[/color][teal]([/teal]opener[teal])[/teal]
[COLOR=darkgoldenrod]alert[/color][teal]([/teal]opener[teal].[/teal]top[teal])[/teal]
[COLOR=darkgoldenrod]alert[/color][teal]([/teal]opener[teal].[/teal]top[teal].[/teal]mv_top[teal])[/teal]
[COLOR=darkgoldenrod]alert[/color][teal]([/teal]opener[teal].[/teal]top[teal].[/teal]mv_top[teal].[/teal]document[teal])[/teal]
[COLOR=darkgoldenrod]alert[/color][teal]([/teal]opener[teal].[/teal]top[teal].[/teal]mv_top[teal].[/teal]document[teal].[/teal]contact[teal])[/teal]
[COLOR=darkgoldenrod]alert[/color][teal]([/teal]opener[teal].[/teal]top[teal].[/teal]mv_top[teal].[/teal]document[teal].[/teal]contact[teal].[/teal]_address1[teal])[/teal]
[COLOR=darkgoldenrod]alert[/color][teal]([/teal]opener[teal].[/teal]top[teal].[/teal]mv_top[teal].[/teal]document[teal].[/teal]contact[teal].[/teal]_address1[teal].[/teal]value[teal])[/teal]
( If you have a console which supports API, better use [tt]console[teal].[/teal]log[teal]([/teal]opener[teal])[/teal][/tt] and so on. You can use it for example in FireBug's Console, DragonFly's Console or the WebKit Inspector's Console. )

Feherke.
 

Oh - one question: Is the page that opened the popup window running at the same domain that the frameset is at?

If not, it could well be a security issue stopping this from working.

Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top