views:

25

answers:

2

I know that may sound silly, but I'm trying to submit a form on a page inside an iFrame, from the parent site.

Here's an example of the form:

        <form action="/add_email" method="post"> 
        <div class="field"> 
            <label for="newEmailAddress" style="width: auto">Add new email address</label> 
            <input type="text" id="newEmailAddress" name="email" value="null" class="text-field" /> 
            <input type="hidden" name="__app_key" value="null"/> 
            <input type="submit" value="Add address and send activation email"> 
        </div> 
        </form>

As you can see, the Submit button, and the form itself both lack a proper name or id, this is not something I have control over. (It's on an external website.)

Any suggestions?

A: 

Since it is an external website — no. The Same Origin Policy prevents it.

If it was the same website then you could communicate across frames and then access the form via its numerical index in the forms object (but you would also likely be able to give it an id and use that instead).

David Dorward
Hmm, is it only Mozilla-based browsers that prohibit this?
Scott
No, this is pretty cross-browser consistent, apparently for security reasons.
tloflin
Understandable. Thanks for your help David.
Scott
Most definitely for security reasons. Create a hidden iframe, load a website into it, access the forms in it with JavaScript, read off the username and password that the browser inserts automatically. (For one simple example of why it would be a terrible idea to allow this).
David Dorward
A: 

When no name is given to the form then form has the default form name in a form of array ie form[]

hence one can create as many forms in script, the default name's index will increase. Hence one can use it accordingly.

nik