문제

I have a page that may or may not refresh itself.

And I have a checkbox that will control it, but I have no idea how to implement it.

I've tried to use <asp:Timer> component, but it doesn't work.

Using setInterval / setTimeout from JS, I can't achieve this.

My question is - What .NET component or JS/Jquery attribute I have to use to achieve this?

도움이 되었습니까?

해결책

You can use this if you are using jQuery:

$(function(){
    
    $('#timercheck').on('change', function () {
       if ($(':checked').length > 0) {
          clearInterval(timer);
       }
    });

    var timer = setInterval(function(){
       window.location.reload();
    },5000);

});

Here #timercheck is the id of checkbox.

Demo @ Fiddle

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top