I want to know if i can have some javascript code in chrome's console that runs even after page reloads. Specifically, I execute the code below where it submits a form but the thing is that loop runs only once because page reloads right after and chromes console will refresh. Is there anyway to keep loop running?
for(i=1; i< 100; i++) {
setTimeout(function(){
jQuery(document.getElementById("username")).attr('value', i)
jQuery(document.getElementById("info")).attr('value', 'KKKK')
document.getElementsByName("submit")[0].click()
}, 1000);
}
Short answer: no. Refreshing the page clears the DOM and any JS.
You have two approaches:
1) You can try to avoid a full-page refresh from your submit; and 2) You can use cookies/session storage to "save your progress" and check for saved progress on page reload.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.