当前位置: 动力学知识库 > 问答 > 编程问答 >

eval - Javascript Recursive Timer Countdown

问题描述:

I'm writting to you for a question that I have since a few days ago.

Obviously everybody knows what this piece of code does, right?

let count = 10;

let clock = setInterval(function(){

count--;

if(count === 0) clearInterval(clock);

}, 1000);

Well, my question is the following since I discovered that eval() can lead to DOM XSS Vulnerabilities.

How I possibly avoid using this kind of eval() functions since I need them to display too many timers (DateTime Countdowns) at my web application.

I was thinking about some sort of recursive functionality to achieve this goal. What do you guys think?

Thanks for your answers!

分享给朋友:
您可能感兴趣的文章:
随机阅读: