We help IT Professionals succeed at work.

How do i change the url of the parent form from an iFrame form?

MitchellVII
MitchellVII asked
on
I have an iFrame subform on my parent form.  When I submit the form on the Iframe subform, I would like to have a Redirect statement that changes the url of the parent form.

How would I do that?
Comment
Watch Question

Kim WalkerWeb Programmer/Technician

Commented:
Do you want to change the url in the parent form "action" attribute or do you want to load a different page in the parent window altogether?

Using javascript, you can access the iFrame parent using the parent object:
parent.document.forms[0].action = 'newurl';
parent.window.location = 'newlocation';

Open in new window

Author

Commented:
I am just looking for the

Response.Redirect()

statement to use in my ASP script.
Web Programmer/Technician
Commented:
Response.Redirect() is a server-side function that tells the server how to respond to a request from a client computer. Once the parent page and iFrame have been loaded, Response.Redirect() is powerless to change the content of either without some client-side activity which generates a new request and then it can only direct that response to the source of the request. The server is powerless to control the content of the parent window through the iFrame window. Only client-side scripting can bridge that gap.

Author

Commented:
Ah ok.

I guess I'll just have to write a "Thanks!" page to pop up in the iFrame instead of redirecting the parent.

Author

Commented:
Wish the answer was different but it is the correct one :)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.