我正在努力解决以下问题:
我想在页面启动时停止加载 div。我已将 div 文件内的内容放在一个额外的文件夹中,该文件夹由 htaccess+htusers 文件保护。
因此,当页面加载时,atm htaccess 问题会立即开始,但它应该只在单击按钮并且文件夹内容应该出现时询问此权限。
是否有可能阻止 div 加载并使用按钮或其他东西强制加载?
最佳答案
我假设您的弹出窗口包含子目录的 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.
});
关于javascript - 在页面加载时阻止 htaccess 弹出窗口的 div 加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36959946/