post - 通过 post 方法将数据发送到 iframe

标签 post iframe moodle

我有一个 iframe,它指向一个 Moodle 站点。我需要将我的用户名和密码传递给它,以便在加载 iframe 时,我会自动登录到 Moodle。所以我有这样的事情:

<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>
</div>

我的问题是如何使用 POST 方法将我的用户名和密码发送到此 URL?

最佳答案

要发布到 iframe,您必须使用 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 - 通过 post 方法将数据发送到 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3803320/

相关文章:

php - 如何编辑 echo $OUTPUT->main_content() MOODLE

c# - 如何找到通过 POST 方法向 asp.net 网页发送数据的网站的 IP 地址?

javascript - Reddit OAuth2 用户身份验证

java - 如何在 Angular JS中发送java对象

iframe - 单击 iframe 时,Bootstrap 下拉菜单不会折叠

windows - 如何在 Windows 本地主机上使用 CodeRunner 模块安装 moodle?

javascript - AJAX POST 不适用于 javascript 到 nodejs

javascript - 2 个视频同一页面使用 iframe Youtube API 只加载一个

javascript - jQuery html() 在 iframe 中失败?

php - 写入数据库时​​出错-Moodle