Nowadays, most websites have the function of "running code", and search bars have also implemented this function for a long time. However, when I was working on a project recently, I found that some needed to be refreshed to see the results. I explored it myself, and the solution is actually very simple. , look at the following code:
function runCode(cod1) {
cod=document.getElementById(cod1)
var code=cod.innerText;
var newwin=window.open('' ,'','');
newwin.opener = null;
newwin.document.write(code);
newwin.location.reload();
newwin.document.close() ;
}
Just add this sentence:
newwin.location.reload();