在页面重定向之前强制DOM刷新(webkit浏览器)

时间:2016-03-25 13:26:17

标签: jquery onclick webkit href adminlte

我尝试在重定向页面之前附加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/Machttp://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);

另外,如果我点击&#34; example.com&#34;的后退按钮并回到上一页,泡沫就在那里。因此,似乎webkit浏览器选择在页面离开之前不刷新页面。

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

此外,如果我在showBubble函数之后将onClick(&#39; 123&#39;)置于onClick属性中,则警报会显示,但页面仍未刷新。

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

我试图摆脱href并做:

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

没有成功。

0 个答案:

没有答案
相关问题