开发者

Timer based redirect problem using window.location

开发者 https://www.devze.com 2023-03-20 15:10 出处:网络
<script language=\"JavaScript\" type=\"text/javascript\"> var theBar = createProgressBar(document.getElementById(\'progress-bar\'));
<script language="JavaScript" type="text/javascript">
        var theBar = createProgressBar(document.getElementById('progress-bar'));

        var value;
        function resetValue() {
            value = 0;
        }

        function showProgress() {
            value += 1;
            theBar.setValue(value);

            if (value < 100) {
                window.开发者_开发知识库setTimeout(showProgress, 100);   
            }
            if (value = 100) {
                window.location = 'http://google.com';
            }   
        }
        window.onload=resetValue();showProgress();
</script>

I'm trying to redirect after the timer reaches 10 sec, but what I tried doesn`t seem to work (redirects instantly).

not familiar with JS one bit, tried my best to mimick


= means assignment

if (value == 100) { ...
0

精彩评论

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