[英]How do I preload HTML that is written by a Javascript on page load?
So here is what I am trying to achieve. 所以这就是我想要达到的目标。 I currently have a FeedBurner script in my webpage.
我的网页上目前有一个FeedBurner脚本。 I use the
<script>
tags for the feed and when the page loads, the script generates the feed HTML. 我对提要使用
<script>
标记,并且在页面加载时,脚本会生成提要HTML。 What I'm trying to do is to have all the HTML associated with the feed to preload and then fade in. I tried putting the script in an external file and making an Ajax call but that didn't actually wait till everything was finished loading. 我想做的是让与提要相关的所有HTML都预先加载,然后淡入。我尝试将脚本放入外部文件中并进行Ajax调用,但实际上并没有等到所有内容加载完成。
I am currently using jQuery. 我目前正在使用jQuery。
Thanks. 谢谢。
Put that code in window load
function instead of DOM Ready 将该代码放入
window load
函数中,而不是DOM Ready中
$(window).load(function() {
// Make ajax request here and check if that helps
});
您可以在身体部位使用这样的JS函数。
<body onload="func()">
Use the ajax call on window.load like Sushanth said along with appending it with display:none and then fading it in. 像Sushanth所说的那样在window.load上使用ajax调用,并在其后面附加display:none,然后使其淡入。
$(window).load(function() {
$content = $.get();
$content.css('display', 'none').appendTo('#my_element').fadeIn()
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.