0

I´m using AutoFill

I'm getting all autofill form of pages that need

I want to put in a javascript variable array all urls

when load the page javascript activate submit the form

and then submit the go to the next url

<iframe src="here url" height="100%" width="100%"></iframe>

Initially I have two doubts:

  • How to activate submit within the iframe with javascript?
  • How do going to the next url array after submit ?

UPDATE

<?php header('Access-Control-Allow-Origin: *');  ?>
<script type="text/javascript" src="jquery-3.1.1.min.js"></script>

<iframe src="http://example.com/contact/" id="InnerIframe" height="100%" width="100%"></iframe>

<script>

$(window).on('load', function() {
   $('#InnerIframe').contents().find('submit').trigger( "click" );
});

</script>

Console log:

jquery-3.1.1.min.js:3197 Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://localhost" from accessing a cross-origin frame.
    at contents (http://localhost/site/jquery-3.1.1.min.js:3197:14)
    at Function.map (http://localhost/site/jquery-3.1.1.min.js:457:13)
    at jQuery.fn.init.jQuery.fn.(anonymous function) [as contents] (http://localhost/site/jquery-3.1.1.min.js:3201:24)
    at http://localhost/site/:8:22
    at dispatch (http://localhost/site/jquery-3.1.1.min.js:5201:27)
    at elemData.handle (http://localhost/site/jquery-3.1.1.min.js:5009:28)contents @ jquery-3.1.1.min.js:3197map @ jquery-3.1.1.min.js:457jQuery.fn.(anonymous function) @ jquery-3.1.1.min.js:3201(anonymous function) @ (index):8dispatch @ jquery-3.1.1.min.js:5201elemData.handle @ jquery-3.1.1.min.js:5009
util.js:208 Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keysPA.j @ util.js:208(anonymous function) @ js?v=3.exp&key&ver=4.6.1:127(anonymous function) @ js?v=3.exp&key&ver=4.6.1:46(anonymous function) @ js?v=3.exp&key&ver=4.6.1:43(anonymous function) @ js?v=3.exp&key&ver=4.6.1:46(anonymous function) @ js?v=3.exp&key&ver=4.6.1:99(anonymous function) @ js?v=3.exp&key&ver=4.6.1:43(anonymous function) @ js?v=3.exp&key&ver=4.6.1:99(anonymous function) @ js?v=3.exp&key&ver=4.6.1:43(anonymous function) @ js?v=3.exp&key&ver=4.6.1:99ic @ js?v=3.exp&key&ver=4.6.1:45hc.Sb @ js?v=3.exp&key&ver=4.6.1:99(anonymous function) @ util.js:1
Gislef
  • 1,285
  • 2
  • 13
  • 33

1 Answers1

1

If I understand you correctly, you load a page, populate a form, then submit it and go to a new URL?

Why would you do this, as in what is the purpose of loading this page if all it does is leave it?

Anyways I would suggest using jQuery for what you want. As seen in here, and the question it is a duplicate of, you can access the iFrame's contents with jQuery using its ID. Then you can use .submit() on the form.

Within your submit method call you can define what you want to do with the form you submitted, as well as redirect to the new page. Maybe using something like

window.location.replace("http://stackoverflow.com");
Community
  • 1
  • 1
Nol
  • 314
  • 2
  • 14
  • Thank you understood correctly. Please see the update in my question. This appearing on the console 'Uncaught DOMException' – Gislef Oct 29 '16 at 15:47
  • I can't help you with that part, but I found another thread that might help. http://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame – Nol Oct 31 '16 at 16:34