好吧,我剛纔提交了一個問題,關於一個動畫加載GIF不顯示圖像上傳(PHP)時。現在,我設法讓圖片上傳時顯示GIF,但在IE和Firefox中,加載GIF永遠不會消失(和/因爲?)表單永遠不會提交。在Chrome中,GIF消失,表單提交。下面是我做吧..表單onSubmit與Javascript不能正常工作在IE和Firefox
<!-- Validates form -->
<script type="text/javascript" src="jquery-1.8.0.js"></script>
<script>
function validationloading(){
// post box blank
var x=document.forms["livefeed"]["message"].value;
if (!$.trim($("#styled").val())){
document.livefeed.message.focus();
document.livefeed.message.style.border="solid 1px red";
alert("Cannot post a blank message.");
return false;
}
document.write("<table cellpadding='0' cellspacing='0' border='0' align='center' width='100%' height='130'><tr><td align='center' valign='center'><img src='images/ajax_loader.gif' width='50' height='50'></td></tr></table>");
return true
$("#myform").submit();
}
</script>
下剪斷就是從形式調用它..
onSubmit="javascript: validationloading()"
我已經試過周圍洗牌返回真值,並將其改變結果,但不是我需要的方式。它會在IE和Firefox中提交,但不顯示加載GIF。我知道我的代碼是一堆斜坡,但這就是我來這裏的原因。
以下在三種瀏覽器中都能100%地工作......感謝所有的幫助!
<!-- validates form and displays loading gif -->
<script type="text/javascript" src="jquery-1.8.0.js"></script>
<script>
function validationloading(){
// post box blank
var x=document.forms["livefeed"]["message"].value;
if (!$.trim($("#styled").val())){
document.livefeed.message.focus();
document.livefeed.message.style.border="solid 1px red";
alert("Cannot post a blank message.");
return false;
}
//
document.livefeed.submit();
document.getElementById("gif_block").style.display="block"; //gif_block is the id of the div outside the image
document.getElementById('livefeed').style.display ='none';
return true;
}
</script>
和GIF DIV是這個..
<div id="gif_block" style="display:none" align="center" ><p><image src="images/ajax_loader.gif" id="loader-img" width="50" height-"50" /></p></div>
好的,我希望我可以接受這兩個..我接受了一個答案。感謝您的高舉。 – user1799250