0

I have a search page which takes time to load results on submit. So i decided to show a loading.gif to keep the user entertained while it loads. below is the javascript function, the div element on jsp and the call to the javascript function.

JS

function goodbye(){
console.log();
var pb = document.getElementById("loading");
pb.innerHTML = '<img src= "images/loadingAnimation.gif" />';
pb.style.display = 'block';
return true;
}

div

<div id="loading" style="position:absolute; width:100%; text-align:20%; top:100px; height: auto; left: 500px;"></div>

Call to JS

<td><html:submit property="method" value="Submit"
                    onclick="return goodbye();" styleClass="btn2" /></td>

i even get "LOG:" on the console. and all java script is on the same page between script tags and not in a seperate .js file

Edit: I have the div tag between the body tag and form tag.

4

3 回答 3

0

我试过你的代码,它对我有用.. 在此处输入图像描述

function goodbye() {
        console.log();
        var pb = document.getElementById("loading");
        pb.innerHTML = '<img src= "../images/loading.gif" />';
        pb.style.display = 'block';
        return true;
    }

我注意到的是,div放置是位置:绝对是导致问题的原因,因为您的div将相对于您的父div放置。它可能会放置在您所期望的其他位置。

我已经给出了调试的边界。你可以试试这个。

 <div id="loading" style="width: 100%;  border:2px solid black"></div>
于 2013-10-30T17:19:48.527 回答
0

当我将 img 标签移动到 div 时,它对我有用。

<div id="loading" style="display:none; position:absolute; width:100%; text-align:20%; top:100px; height: auto; left: 400px;">
<img src= "images/load.gif" /></div>

但是感谢所有尝试过的人。

于 2013-11-01T17:58:08.827 回答
-1

替换onclick="return goodbye();"onclick="goodbye()"

于 2013-10-30T16:34:02.043 回答