Page 1 of 1

Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 11:37 am
by phppage
Hi

Would anyone know a way or if its possible to submit a form on a child window from a parent window taking in to account that both windows are on different domains?
I have tried the obvious

Code: Select all

childwindow.onload = "document.formname.submit()";

Cheers

Re: Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 11:52 am
by Christopher
When you create the child window, save the window ID and use it to reference the child window's elements.

Re: Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 12:01 pm
by phppage
arborint wrote:When you create the child window, save the window ID and use it to reference the child window's elements.
I think I may have tried that. Do you mean like this?

Code: Select all

page1=window.open('http://www.example.com/form','page1');
page1.document.formname.submit();
Unfortunately that doesn't work but this does.

Code: Select all

page1=window.open('http://www.example.com/form','page1');
page1.close();
Think this may be some kind of security feature on the browser I wonder.

Re: Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 12:14 pm
by phppage

Code: Select all

page1=window.open('http://www.example.com/form','page1');
page1.document.formname.submit();
Just noticed a Access Denied error for the above on the browser. Would anyone know of a browser that would allow me to do this?

Re: Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 12:27 pm
by phppage
Get a similar error in Fire fox and found this page that explains why.

https://bugzilla.mozilla.org/show_bug.cgi?id=308667

Would anyone know of a browser that dose not do this?

Cheers

Re: Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 12:33 pm
by VladSun
phppage wrote:... windows are on different domains ...
Due to security reasons the browser would not allow this action. I know you can switch this protection off in IE ... not sure about doing this in other browsers.

Re: Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 12:46 pm
by phppage
VladSun wrote:
phppage wrote:... windows are on different domains ...
Due to security reasons the browser would not allow this action. I know you can switch this protection off in IE ... not sure about doing this in other browsers.
Many thanks for this. Would you mind telling me how I switch this off in IE?

Re: Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 12:52 pm
by VladSun
Indeed, I'm sure there has been such an option in IE 5.5 but I can't find it in IE 7.0.
It was called "Cross domain scripting" or something like that, in Advanced Options tab in Internet options menu.

Re: Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 2:47 pm
by phppage
VladSun wrote:Indeed, I'm sure there has been such an option in IE 5.5 but I can't find it in IE 7.0.
It was called "Cross domain scripting" or something like that, in Advanced Options tab in Internet options menu.
Cheers for looking. Found the setting but it dose not seem to work. It's in the Zone section of IE settings.

Would anyone know of another browser apart from IE that allows cross domain scripting?

Re: Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 3:03 pm
by nickvd
phppage wrote:
VladSun wrote:Indeed, I'm sure there has been such an option in IE 5.5 but I can't find it in IE 7.0.
It was called "Cross domain scripting" or something like that, in Advanced Options tab in Internet options menu.
Cheers for looking. Found the setting but it dose not seem to work. It's in the Zone section of IE settings.

Would anyone know of another browser apart from IE that allows cross domain scripting?

I don't think you'll find one... It would be a major security problem if the browser was able to interact like that. Is this for a publicly available site?

Re: Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 3:26 pm
by phppage
nickvd wrote:
phppage wrote:
VladSun wrote:Indeed, I'm sure there has been such an option in IE 5.5 but I can't find it in IE 7.0.
It was called "Cross domain scripting" or something like that, in Advanced Options tab in Internet options menu.
Cheers for looking. Found the setting but it dose not seem to work. It's in the Zone section of IE settings.

Would anyone know of another browser apart from IE that allows cross domain scripting?

I don't think you'll find one... It would be a major security problem if the browser was able to interact like that. Is this for a publicly available site?
Yes, but I own the site I am trying to submit to but can not change the code very easily for reasons that would take to long to explain. Really frustrating really. Its only my self that would need to do this as well so I would not have worry about Joe Bloggs the user.

Re: Parent window submitting a form on child?

Posted: Sat Jan 12, 2008 11:47 pm
by John Cartwright
Not how I would approach the solution to the problem, nor do I recommend you continue down this path..

but any older browser, i.e. the old Netscape's probably lack this security.

Re: Parent window submitting a form on child?

Posted: Sun Jan 13, 2008 9:13 pm
by Ambush Commander
With an appropriate crossdomain.xml policy file, Flash can submit pages on other domains. Research that.