Home >Web Front-end >JS Tutorial >js solution to the need to refresh running code_javascript skills

js solution to the need to refresh running code_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:10:071332browse

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();

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn