上下文:我预览sendform结果在一个iFrame -当然,提交按钮被放置在父页面。所有的网页都在同一个域
我喜欢隐藏提交按钮(在iFrame的条件下)。
在父页:
function hidesubmit() {
$('#submitdiv').hide(); // hide button
};
<iframe class="iframe_" frameborder="0" name="preview" onload="resizeIframe(this);" scrolling="no"></iframe>
在php脚本(在iFrame)我有这一行不工作
window.parent.hidesubmit();
在父页(添加):
<div class="preview" id="preview">
<iframe class="iframe_" frameborder="0" name="preview" onload="resizeIframe(this);" scrolling="no"></iframe>
<div id="animated" style="text-align:center; display:block;" ><img src="/templates/Gazette/Images/animateround.gif" width="124" height="124" vspace="5" /></div>
命令/突击队通过✉(% % GLOBAL_Protocol % %) <div class="espacesubmit" id="submitPhoneOnly">
<button class="buttonsubmit" name="_Commande" onclick="return checkform();" type="submit">
Order via Phone only / Commande par Tél. uniquement<br />
(您可以提交以获得一份副本/您可以提交一份表格或接收一份副本)
您只能对父类操作,如果它在同一域中。(见SOP)。
如果它在同一域中,那么您需要使用window.top
。
,
window.top.hidesubmit();
另一种方法是在父表单上添加一个事件"onsubmit()",如下所示:
<form name='myForm' action='...' method='...' onsubmit='hidesubmit();return true;'>
...
</form>
停止使用iframe
。
- 老!很老! 这不是一个好的做法。
- 很难操作
你不需要那个。你只是不知道。
另使用一个简单的ajax请求来获取你想要的东西,并且将写入你的页面
- 调用页面
- 获取结果(纯html没有页眉/页脚,只有内容)
- 用
.html()
/.append()
写在你的html页面
可能的解决方案
见https://developer.mozilla.org/en/DOM/window.parent
ẃindow.parent.hidesubmit();
似乎你正试图从PHP内执行javascript调用。您需要将其包含在脚本块中,例如:
$boutonnosubmityet = '<div id="nosubmityet"><button class="ButtonsVerifier"
name="_NoSubmit"> Missing - Info - Manquante<br/>Your information </button></div>'
. '<script type="text/javascript">window.parent.hidesubmit();</script>';