0

我试图Loading state在页面重定向之前附加一个 div。(https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html

我的页面上有以下链接:

<a onclick="showBubble('bubble-placeholder'); return true;" href="http://example.com">Link
</a>

function showBubble(boxClass) {
    $('.' + boxClass).append('<div class="overlay"><i class="fa fa-refresh fa-spin"></i></div>');
}

单击链接时,showBubble 会将一个 div 附加到页面上的另一个 div 上。然后重定向到http://example.com

它在所有浏览器中都可以正常工作,但在 Ipad 上的 webkit 浏览器中却不行。

我在这里发现了类似的问题Force DOM redraw/refresh on Chrome/Mac和这里http://www.eccesignum.org/blog/solving-display-refreshredrawrepaint-issues-in-webkit-browsers

但是这些解决方案都不适合我。我试过了:

$('#parentOfElementToBeRedrawn').hide().show(0);

$(window).trigger('resize');

var n = document.createTextNode(' ');
$('#myElement').append(n);
setTimeout(function(){n.parentNode.removeChild(n)}, 0);

此外,如果我单击“example.com”中的后退按钮并返回上一页,则会出现气泡。因此,似乎 webkit 浏览器选择在离开页面之前不刷新页面。

此外,我没有将元素附加到框中,而是尝试了一些更简单的方法——比如更改我的一个按钮的文本。它也不起作用。点击链接后页面不刷新。

此外,如果我在 showBubble 函数之后将 alert('123') 放在 onClick 属性中,则会显示警报,但页面仍未刷新。

但是,如果我从标签中删除 href 属性,<a>气泡就会出现并且一切正常。好吧,除了它不再是链接了:)

我试图摆脱 href 并做:

onclick="showBubble('bubble-placeholder'); window.location.replace('www.example.com');"

没有成功。

4

0 回答 0