Jquery加载图像在页面上的特定时间
Jquery Loading image on Page for specific Time
我有一个div,它有一个Image Loader图像。我想在div中显示图像,一旦我调用价格计算函数,图像应该显示在整个页面上。请帮帮我
<div class="Progress_Layout" style="display:none">
<div class="Progress_Content">
<div>
<img src="@Url.FilePath(FileTypes.IMAGES, "loader", "10271456A2B3")" style="vertical-align: middle" alt="" />
</div>
<div class="Progress_Text">
@DffUtility.GetGlobalResource("pleaseWait")
</div>
</div>
</div>
这是计算价格时调用的Jquery函数。
function CalculatePrice() {
var req, parameters, datasend, prodlist;
LOADING = setInterval(function () {
$('.objprice', prodlist).html(LOADINGIMG);
}, 5);
LOADING = setInterval(function () {
$("body").html($(".Progress_Layout"));
}, 5);
var querystring = "?" + BASIC_PARA + "&" + GetPriceCalculationQueryString() + "&filter=" + FILTER + "&sort=1&FilterChange=0&cacheprod=0";
if (PAGE_TYPE < 3) {
querystring = querystring + "&dumy=1",
datasend = "";
} else {
req = {
RefID: REFIDLIST
};
datasend = JSON.stringify(req);
datasend = encodeURIComponent(datasend);
}
URL_QUERYSTRING = querystring;
UpdateLabels();
Searchcontrol(2);
if (ISREFID == "" && LANDWITHPRICE == false) {
smoothScroll('prodlistinsp', 300);
}
parameters = "prodrq=" + datasend;
if (document.domain.indexOf("localhost") != -1 || document.domain.indexOf("tenbook") != -1) {
makeRequest(TENWEB_PATH + "/inspiration/PriceCalculatorPage.aspx" + querystring, parameters);
} else {
makeRequest("http://" + document.domain + "/" + PROXYPAGE + querystring, parameters);
}
}
可以通过以下结构实现:
HTML:<div id="loadingImage"></div>
<div id="loadingOverlay"></div>
CSS: #loadingImage {
background: url(http://loadinggif.com/images/image-selection/17.gif)
no-repeat center center;
height: 64px;
width: 64px;
position: fixed;
z-index: 11111;
left: 50%;
top: 50%;
margin: -25px 0 0 -25px;
display: none;
}
#loadingOverlay {
display: none;
width: 100%;
height: 100%;
left: 0px;
top: 0px;
position: fixed;
z-index: 1;
background-color: black;
opacity: 0.5;
}
JS:在calculatePrice()
开始时调用showLoader()
,然后在指定的超时时调用hideLoader。
function calculatePrice(){
showLoader();
setTimeout(hideLoader, 1000);
}
function showLoader(){
document.getElementById('loadingImage').style.display = 'block';
document.getElementById('loadingOverlay').style.display = 'block';
}
function hideLoader(){
document.getElementById('loadingImage').style.display = 'none';
document.getElementById('loadingOverlay').style.display = 'none';
}
相关文章:
- 如何使用url加载程序在webpack中导入多个图像
- 如何在生成下载文件时显示加载动画
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- 无法在通过jQuery的ajax加载的页面中执行javascript
- Emberjs应用程序加载在除Index之外的所有路由上
- vue.js使用定时器自动重新加载/刷新数据
- Chrome 49 定时和使用 require.js 模块的加载错误
- 定时 Javascript 文件刷新,无需重新加载页面
- kineticJS按顺序加载图像(并设置fillPatternImg)不透明度补间不起作用
- 使用 ngModel 作为绑定时,文本区域中加载的文本中的跳线会丢失
- 重新加载页面时控制器间通信失败
- 定时跨域页面加载时间
- 当它应该是一个定时事件时,音频播放加载
- 使用imagesLoaded将页面加载器定时为可见图像计时
- 在SWFObject上加载定时器用于SWF加载时间
- 滚动调整在非ie浏览器加载图像(JavaScript/DOM)后不能正常工作;定时问题w/innerHTML
- 在Netsuite定时脚本中从外部URL加载和读取CSV
- 编写Javascript库:异步加载定时问题
- 补间.js使用三.js加载器时旋转不起作用
- 即使没有人使用,也要定时重新加载网页