简体   繁体   English

为某些移动设备/浏览器提交表单后 Gif 未加载

[英]Gif not loading after form is submitted for certain mobile devices/browsers

After my HTML form is submitted, it takes a while for all the data to process and for the user to be redirected to the new page where the output will be shown.提交我的 HTML 表单后,需要一段时间来处理所有数据并将用户重定向到将显示 output 的新页面。 After the form is submitted, I want to hide it and then display a processing gif until the user is redirected.表单提交后,我想隐藏它,然后显示一个处理 gif,直到用户被重定向。

My code works for Chrome on the computer.我的代码适用于计算机上的 Chrome。 But for mobile browsers, all the code in displayProcessingGif() runs except for the first line, which is supposed to make the gif show up.但是对于移动浏览器, displayProcessingGif()中的所有代码都会运行,除了第一行,它应该让 gif 显示出来。 For Safari on the computer, none of the code in displayProcessingGif() runs.对于计算机上的 Safari, displayProcessingGif()中的代码均未运行。

Any help would be greatly appreciated.任何帮助将不胜感激。

<script type="text/javascript">
    function displayProcessingGif(){
        document.getElementById("processingGif").innerHTML='<img src="examplewebsite.com/examplegif.gif">';
        document.getElementById("myForm").style.display="none";
    }
</script>

<form method="POST" id="myForm">
    //different form contents
    <input type="submit" value="Submit!" name="submit" onclick="displayProcessingGif();">
</form>

<div id="processingGif">
    <img src="">
</div>

Changing innerhtml has its own problems.更改 innerhtml 有其自身的问题。 Why don't you rather change image src ?你为什么不改变图像src

<script type="text/javascript">
    function displayProcessingGif(){
        document.getElementById("processingImg").src='examplewebsite.com/examplegif.gif';
        document.getElementById("myForm").style.display="none";
    }
</script>

<div id="processingGif">
    <img src="" id="processingImg">
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM