How to refresh page with javascript for N number of times through user input?

后端 未结 3 1621
别那么骄傲
别那么骄傲 2021-01-25 18:11

i have coded a script that should refresh the page for Number of times the user input the value . here is the code

3条回答
  •  盖世英雄少女心
    2021-01-25 18:49

    I agree with Matt Morgan that your attempt to assign a variable inside a conditional:

    if ( reloadCnt <= var x = document.getElementById('a').value; )
    

    probably means you need to brush up on your understanding before proceeding.

    But here is a working demo for you. (Not having your index.php, which I assume populates the textbox "a", I've done it client-side and fetched the posted value from the querystring. Once you've got it working, you can always revert to document.getElementById('a').value)

    You'll also want to clear your sessionStorage variable when the user next hits the page, otherwise when you try to test it twice in a row, reloadCounter will still be where it was at the end of the last run.

    Your link:

    number of times:

提交回复
热议问题