Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Javascript的另一个页面中传输进度条?_Javascript_Progress Bar - Fatal编程技术网

在Javascript的另一个页面中传输进度条?

在Javascript的另一个页面中传输进度条?,javascript,progress-bar,Javascript,Progress Bar,我有一个显示进度条的Javascript函数 <script type="text/javascript"> Counter = 10; function DoCounter() { SlideParent = document.getElementById("SliderParent"); Slide = document.getElementById("Slider"); Slide.style.width = Counter + "%"; Sli

我有一个显示进度条的Javascript函数

<script type="text/javascript">
Counter = 10;
function DoCounter()
{
    SlideParent = document.getElementById("SliderParent");
    Slide = document.getElementById("Slider");
    Slide.style.width = Counter + "%";
    Slide.innerHTML = Counter + "%";
    if(Counter <25)
    {
        SlideParent.style.borderColor = "green";
        Slide.style.backgroundColor = "green";
    }
    else if(Counter >= 25 && Counter < 50)
    {
        SlideParent.style.borderColor = "blue";
        Slide.style.backgroundColor = "blue";
    }
    else if(Counter >= 50 && Counter < 75)
    {
        SlideParent.style.borderColor = "orange";
        Slide.style.backgroundColor = "orange";
    }
    else
    {
        SlideParent.style.borderColor = "red";
        Slide.style.backgroundColor = "red";
    }
    if(Counter++ < 100)
    {
        setTimeout("DoCounter()",100);
    }
}

</script>

计数器=10;
函数DoCounter()
{
SlideParent=document.getElementById(“SliderParent”);
Slide=document.getElementById(“Slider”);
Slide.style.width=计数器+“%”;
Slide.innerHTML=计数器+“%”;
如果(计数器=25&&计数器<50)
{
SlideParent.style.borderColor=“蓝色”;
Slide.style.backgroundColor=“蓝色”;
}
否则如果(计数器>=50和计数器<75)
{
SlideParent.style.borderColor=“橙色”;
Slide.style.backgroundColor=“橙色”;
}
其他的
{
SlideParent.style.borderColor=“红色”;
Slide.style.backgroundColor=“红色”;
}
如果(计数器+++<100)
{
setTimeout(“DoCounter()”,100);
}
}
这是我体内的标签:

<div id="sync"><input type="submit" onclick="DoCounter();" /></div>
<div id="SliderParent" style="width:100%;">
    <div id="Slider" style="width:0%; border-width:0px; background-color:red; color:white">
        0%  
    </div>
</div>

0%  

当用户单击“提交”时,进度条将加载到同一页面中。我希望将进度条加载到同一页面,但删除所有内容<代码>文档。写入(“上载..请稍候”)执行此操作。我想删除所有内容并添加
上传..请等待
和下面的进度条。我该怎么做?

永远不要将字符串传递给
setInterval()
setTimeout()
。这样做与使用
eval()
一样糟糕,而且在使用变量时会导致代码无法读取,甚至可能不安全,因为您需要将变量插入字符串中,而不是传递实际的变量。正确的解决方案是
setInterval(function(){/*您的代码*)},毫秒)。这同样适用于
setTimeout()
。如果您只想在没有任何参数的情况下调用单个函数,还可以直接传递函数名:
setInterval(someFunction,毫秒)(请注意,函数名后面没有
()
)谢谢您的提醒。现在,我如何才能达到我的结果?谢谢