作者:jizi456 | 来源:互联网 | 2023-09-25 11:04
IhaveawebpagewhichheavilymakesuseofjQuery.我有一个使用jQuery的网页。Mygoalistoonlyshowthepa
I have a webpage which heavily makes use of jQuery.
我有一个使用jQuery的网页。
My goal is to only show the page when everything is ready.
我的目标是只在一切就绪时显示页面。
With that I want to avoid showing the annoying page rendering to the user.
这样,我想避免向用户显示烦人的页面呈现。
I tried this so far (#body_holder
is a wrapper inside body):
我已经尝试过了(#body_holder是一个内部包装器):
$(function(){
$('#body_holder').hide();
});
$(window).load(function() {
$("#body_holder").show();
});
This works completely fine, but messes up the layout.
这样做完全没问题,但会打乱布局。
The problem is that hiding the wrapper interferes with the other jQuery functions and plugins used (eg layout-plugin).
问题是隐藏包装器会干扰使用的其他jQuery函数和插件(如layout-plugin)。
So I guess there must be another trick to do this. Maybe lay a picture or div over the body until window.load has occurred?
所以我猜肯定还有别的办法。也许在身体上放一张图片或div,直到窗口。负载发生吗?
What approaches do you use?
你用什么方法?
EDIT:
编辑:
The solution most likely has to be another way than display:none
or hide()
;
解决方案很可能是另一种方式,而不是显示:none或hide();
4 个解决方案