开发者

unable to add gif to web page with javascript

I have a web page with a link called "Download". When user press that link, I'm using javascript to add a gif animation so that user knows that the system is busy. Here is the code:

function submit_form()
{
  var nfy = document.getElementById('nfy_area');
  var img = document.createElement( 'img' )开发者_如何学C;
  img.setAttribute('src', 'images/wait24trans.gif');
  nfy.innerHTML = "This will take a few minutes. Please be patient...";
  nfy.appendChild( img );
  document.forms["download_form"].submit();
}

However, this only works for Opera. For Chrome, nothing is displayed. For Firefox, a broken image is displayed.

Why?

Thanks,


Check out broken images on firefox to see where does it search for image to fix the src.


For what it's worth, the HTML5 spec is likely to require that the submit() call there imply a stop() call.


SOLVED: The target of the submit action is another page. So presumably both FF and Chrome detect this and stops loading anything else on the current page. I put in a delay before submitting the form and now it works fine.

Commendably, Opera works perfectly well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜