通过post方法将数据发送到iframe [英] Sending data through post method to an iframe
本文介绍了通过post方法将数据发送到iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个指向moodle网站的iframe。我需要传递我的用户名和密码,以便在加载iframe时,我会自动登录moodle。所以我有这样的事情:
I have an iframe which is pointing to a moodle site. I need to pass to it my username and password, so that when the iframe is loaded, I am automatically logged in on moodle. So I have something like this:
<div id="iframe" style="width:787px; height:700px;">
<iframe id="iframeCon" src ="http://www.somesite.net/moodle/login/index.php" width="100%" height="100%" frameborder="0">
</iframe>
我的问题是如何发送我的用户名和密码使用POST方法到这个URL?
My question is how to send my username and password using POST method to this URL?
推荐答案
要POST到iframe,你必须使用表格目标
。
To POST to an iframe you must use form target
.
<form id="moodleform" target="iframe"
method="post" action="http://www.example.com/login/index.php" >
<input type="hidden" name="username" value="guest"/>
<input type="hidden" name="password" value="guest"/>
<input type="hidden" name="testcookies" value="1"/>
</form>
<iframe name="iframe"></iframe>
<script type="text/javascript">
document.getElementById('moodleform').submit();
</script>
这篇关于通过post方法将数据发送到iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文