[英]How to send parameter to Iframe with a HTTP POST request
我必須使用 POST 方法向 IFRAME 發送一些參數。 我已閱讀此處設置不可能的 <iframe> 的 HTTP 請求類型。 我正在考慮 Javascript 中的解決方案,但我無法實現它,所以我無法測試它是否是解決此問題的有效解決方案。 我想問是否有人有同樣的問題,是否有可能解決,在積極的情況下如何解決?
<form ... target="hidden_iframe">
...
</form>
<iframe name="hidden_iframe" ...></iframe>
用表單的target屬性指向iFrame怎么樣?
<form target="myIframe" action="http://localhost/post.php" method="post">
<input type="hidden" value="someval" />
<input type="submit">
</form>
<iFrame src="" name="myIframe"></iFrame>
只是舉一個具體的工作例子
<form id="loginForm" target="myFrame" action="https://localhost/j_spring_security_check" method="POST">
<input type="text" name="j_username" value="login" />
<input type="text" name="j_password" value="password" />
<input type="submit">
</form>
<iframe name="myFrame" src="#">
Your browser does not support inline frames.
</iframe>
// Hide the form and do the submit
<script>
$(document).ready(function(){
var loginform= document.getElementById("loginForm");
loginform.style.display = "none";
loginform.submit();
});
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.