1

My code doesn't submit automatically. What's wrong with my code? I am trying to auto login a remote website via iframe.

<form id="login" target="frame" method="post" action="https://remote.com">
<input type="hidden" name="username" value="login" />
<input type="hidden" name="password" value="pass" />
</form>

<iframe id="frame" name="frame"></iframe>

<script type="text/javascript">
// submit the form into iframe for login into remote site
document.getElementById('login').submit();

// once you're logged in, change the source url (if needed)
var iframe = document.getElementById('frame');
iframe.onload = function() {
if (iframe.src != "https"//remote.com") {
    iframe.src = "https://remote.com";
}
} 
</script>

2 Answers2

0

Try this

<script>
$(document).ready(function(){
 $("#login").submit();
});

Nishant Nair
  • 1,999
  • 1
  • 13
  • 18
0

i try your code your code is submitting automatically

if you want to try your code submitting automatically or not you can use any link with http it will be submit

problem in iframe src https link it not allowed

If your page is http then it allows iframe with https content.

But if your page is https then it does not allow http content.

Lets put down following possibilities.

page - iframe - status

http - http  - allowed
http - https - allowed
https- http  - not allowed
https- https - allowed

Reference ==> Click here

Community
  • 1
  • 1
Ehsan Ilahi
  • 298
  • 5
  • 15