I need to automatically log in to an external site via iFrame. I do not have access to make changes to the site within the iFrame. Security concerns are out of scope for this project.
Functionally it needs to work like this. Here is the code inspired by that link:
HTML
<form id="login" target="frame" method="post" action="foo.com">
<input type="hidden" name="userid" value="username" />
<input type="hidden" name="password" value="password123" />
</form>
<button id="send">Submit</button>
<div>
<iframe id="frame" name="frame" src="https://foo.com"></iframe>
</div>
JavaScript
$('#send').click(function () {
document.getElementById('login').submit();
});
Running this code gives an error, stating that a required parameter was missing from the url. Manually logging in gives no error. I have no console errors.