【问题标题】:Block a div load at page-load for the htaccess popup在 htaccess 弹出窗口的页面加载时阻止 div 加载
【发布时间】:2016-05-02 14:38:07
【问题描述】:

我正在努力解决以下问题:

我想在页面启动时停止加载 div。我将 div 文件中的内容放在一个额外的文件夹中,该文件夹由 htaccess+htusers 文件保护。

所以 atm htaccess 问题在页面加载时立即开始,但它应该只询问这个权限,当单击按钮并且应该出现文件夹内容时。

是否有可能停止加载 div 并通过按钮或其他方式强制加载?

【问题讨论】:

    标签: javascript jquery html .htaccess


    【解决方案1】:

    我假设您的弹出窗口包含一个指向子目录的 iframe。在这种情况下,您可以通过省略(省略)src 属性并仅在单击打开弹出窗口的按钮时分配它来延迟该 iframe 的加载。

    首先声明一个空的iframe,如下所示:

    <iframe id="popup1"></iframe>
    

    然后,使用 jQuery,在单击按钮时将 src 属性分配给 iframe

    $('button#openPopup').on('click', function (event) {
        // Set the src location
        $('iframe#popup1').prop('src', 'http://domain.com/frame-location');
        // Now open the popup the way you normally would.
    });
    

    您还可以将位置存储在data HTML5 属性中,并在单击按钮时从那里调用它:

    <iframe id="popup1" data-src="http://domain.com/frame-location"></iframe>
    
    $('button#openPopup').on('click', function (event) {
        $frame = $('iframe#popup1'); // Assign the frame
        $frame.prop('src', $frame.data('src')); // Set the src location from data attribute
        // Now open the popup the way you normally would.
    });
    

    【讨论】:

    • 我花了一点时间才明白我到底要把它放在哪里,但最后你的代码帮助解决了这个问题!非常感谢!!
    猜你喜欢
    • 2018-06-03
    • 1970-01-01
    • 2017-03-03
    • 1970-01-01
    • 1970-01-01
    • 2012-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多