Parent window submitting a form on child?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
phppage
Forum Contributor
Posts: 126
Joined: Mon Apr 24, 2006 1:47 pm
Location: West Yorkshire, UK

Parent window submitting a form on child?

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Parent window submitting a form on child?

Post by Christopher »

When you create the child window, save the window ID and use it to reference the child window's elements.
(#10850)
User avatar
phppage
Forum Contributor
Posts: 126
Joined: Mon Apr 24, 2006 1:47 pm
Location: West Yorkshire, UK

Re: Parent window submitting a form on child?

Post 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.
User avatar
phppage
Forum Contributor
Posts: 126
Joined: Mon Apr 24, 2006 1:47 pm
Location: West Yorkshire, UK

Re: Parent window submitting a form on child?

Post 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?
User avatar
phppage
Forum Contributor
Posts: 126
Joined: Mon Apr 24, 2006 1:47 pm
Location: West Yorkshire, UK

Re: Parent window submitting a form on child?

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Parent window submitting a form on child?

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
phppage
Forum Contributor
Posts: 126
Joined: Mon Apr 24, 2006 1:47 pm
Location: West Yorkshire, UK

Re: Parent window submitting a form on child?

Post 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?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Parent window submitting a form on child?

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
phppage
Forum Contributor
Posts: 126
Joined: Mon Apr 24, 2006 1:47 pm
Location: West Yorkshire, UK

Re: Parent window submitting a form on child?

Post 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?
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Re: Parent window submitting a form on child?

Post 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?
User avatar
phppage
Forum Contributor
Posts: 126
Joined: Mon Apr 24, 2006 1:47 pm
Location: West Yorkshire, UK

Re: Parent window submitting a form on child?

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Parent window submitting a form on child?

Post 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.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Parent window submitting a form on child?

Post by Ambush Commander »

With an appropriate crossdomain.xml policy file, Flash can submit pages on other domains. Research that.
Post Reply