0

我想使用 BlockUI jQuery 插件阻止 IFRAME 元素。

请给我一个例子如何做到这一点。

4

3 回答 3

1

您是否考虑过查看 BlockUI 文档?

我认为http://jquery.malsup.com/block/#element正是您想要的。我不完全确定在 iframe 加载外部站点的情况下这是否有效,因为它似乎修改了元素的 DOM 而不仅仅是在元素外部创建覆盖。

于 2011-02-02T07:32:13.950 回答
0

在 jquery.block.js 之前包含脚本 jquery.min.js,工作示例:

<html>
<head runat="server">
    <title>BlockUISample</title>
    <script src="<%: Url.Content("~/Scripts/jquery-1.4.4.min.js") %>" type="text/javascript"></script>
    <script src="<%: Url.Content("~/Scripts/jquery.blockUI.js") %>" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#btn').click(function () {
                $('#iframeContainer').block({ message: null });
            });
        }); 
    </script>
</head>
<body>
    <div>
        <input type="button" id="btn" value="block"></input>
        <div id="iframeContainer" style="width: 800; height: 600px;">
            <iframe src="http://www.google.com" width="100%" height="100%"></iframe>
        </div>
    </div>
</body>
</html>
于 2011-08-01T07:44:39.627 回答
0

我相信这就是你的追求。正如 ThiefMaster 所解释的,您需要在 iframe 周围包裹一个外部 DIV 元素。

<div id="iframeContainer" style="width:800;height:600px;">
    <iframe src="http://www.google.com" width="100%" height="100%"></iframe>
</div>

<script type="text/javascript">
    $(function () {
        $('#btn').click(function () {
            $('#iframeContainer').block({ message: null });
        });
    }); 
</script>
于 2011-02-02T08:52:30.633 回答