English 中文(简体)
• 如何在 jQuery点击活动中展示不透明的背景
原标题:How to show opaque background on jQuery click event

In order to show an opaque background or animated gif while executing some method after an button click fails to show this. It only runs after all the code has been executed.

在“Qu”中,我可以这样做,即在一次点击事件上,在主要法典之前和之后使html发生变化。

长期运行的方法是,在网页上增加100-500分机,大约需要10秒钟。

$( #button).click(function() {   
    $( #curtain ).css( visibility ,  visible );
    longRunningMethod();    
    $( #curtain ).css( visibility ,  hidden );  
 });    

The problem is that the #curtain div never shows, as the complete javascript has to be executed before rendering all the changes.

形式:


#curtain {
    position: fixed;
    _position: absolute;
    z-index: 99;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    _height: expression(document.body.offsetHeight + "px");
    background-color: #CCCCCC;
    filter:alpha(opacity=50);
    -moz-opacity:0.5;
    -khtml-opacity: 0.5;
    opacity: 0.5;
    visibility: hidden;
}

最佳回答

这是一种黑板,但如果你使用一套 set。 它可能发挥作用。

$( #button ).click(function() {   
    $( #curtain ).css( visibility ,  visible );
    setTimeout(doBigJob, 100);
 });

function doBigJob()
{
    longRunningMethod();    
    $( #curtain ).css( visibility ,  hidden );
}
问题回答

你们永远不应该在一个网页的坐标线上拥有长期的方法。 该网页似乎锁定,而且对用户来说,该网页是很空洞的。

相反,你应当使用同步呼吁。 我所假设的漫长运行方法是一些美国宇宙航空研究开发机构发出的呼吁。 在此情况下,它应当接受一种作为论点的职能(如“lick”、“aj”等)。 然后,随着完成或成功退步,将这一功能转嫁给麻省法。

然后,你可以做到:

$( #button).click(function() {   
    $( #curtain ).css( visibility ,  visible );
    longRunningMethod(function() {$( #curtain ).css( visibility ,  hidden );});
 });




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签