首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用javascript启用/禁用IFrame中子模式弹出的父模式弹出按钮

问如何使用javascript启用/禁用IFrame中子模式弹出的父模式弹出按钮
EN

Stack Overflow用户
提问于 2014-07-22 02:05:27
回答 1查看 1.1K关注 0票数 0

我正在尝试从子窗口禁用/启用父窗口的一个按钮。

下面是父页的片段。

代码语言:javascript
复制
<ajaxToolkit:ModalPopupExtender ID="mpeTest" runat="server" 
  CancelControlID="btnClose" PopupControlID="pnl1" TargetControlID="showMpe"/>

<asp:Panel ID="pnl1" runat="server" >
           <ContentTemplate>
                <iframe id="ContentIframe" runat="server">
                        <p>Your browser does not support iframes.</p>
                </iframe>
            </ContentTemplate>
    <p class="submitButton">
        <asp:Button ID="btnClose" runat="server" Text="Close" />
        &nbsp;
        <asp:Button ID="btnTest" runat="server" Text="EnableDisable" />
    </p>
</asp:Panel>

在加载在iframe中的子页面中,我有一个带有LinkButtons的网格视图。我正在尝试从父窗口中获取一个LinkButtons来禁用/启用btnTest。

我试过很多东西,但我似乎想不出.例如:

代码语言:javascript
复制
<script type="text/javascript" >
    $(document).ready(function() {
        jQuery('[id$="linkButtonDisable"]').click(function() {
           window.parent.opener.document.getElementById("btnTest").disabled = true;
        });
    });
</script>

有人能帮帮我吗。我对这件事相当陌生

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-22 02:58:05

也许你应该试试这样的..。

代码语言:javascript
复制
$("#<%=linkButtonDisable.ClientID %>").click(function() {

       //Option N#1 HTML Attribute 
       $("#<%=btnTest.ClientID %>").attr("disabled","disabled");

       //Option 2 With jQueryMobile integration, the same it supposed to work if your using bootstrap, but I ignore the css class for disabling an element
       $("#<%=btnTest.ClientID %>").addClass("ui-disabled");

       //Also if you want to toggle states between disable/enable maybe this could work either...
       var id = $("#<%=btnTest.ClientID %>"); 
       var state = id.attr("disabled");
       //Dunno if it's needed to catch if disabled attr it isn't set
       if(state == "disabled") {
           id.removeAttr("disabled");
       } else {
           id.attr("disabled","disabled");
       }

});

希望能帮上忙!.

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24877781

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档