0

I did a test:

<script>
function go() {
    var a = "{tester.string1}";
    alert(a);
}

function change() {
    document.documentElement.innerHTML = document.documentElement.innerHTML.replace(/\{tester\.string1\}/, "replaced!");
}
</script>
<input type="button" value="Go" onclick="go();"/>
<input type="button" value="Change" onclick="change();"/>

The value of a inside go() changed after I clicked/called change()(in Inspect Elements). However, the actual value appear in alert() still shows {tester.string1}. Does this mean the browser won't recompile anything after the page is loaded? (So it's static?) Is there any signal or call I can send to the browser (without reload) for this purpose? I'm not asking anything about eval(). I just want to clarify the concept.

Scott Johnson
  • 288
  • 2
  • 12
Wilson Luniz
  • 459
  • 2
  • 7
  • 18
  • 1
    You are assigning it once function is being called.. – Rayon Oct 17 '15 at 08:07
  • `document.documentElement.innerHTML` is off the topic here! – Rayon Oct 17 '15 at 08:10
  • @RayonDabre — What? `innerHTML` is the main feature of the topic here. – Quentin Oct 17 '15 at 08:23
  • @Quentiin I said I'm not asking anything about `eval()`. I knew `eval()` is a solution for my case. But I'm not heading for **solution**. I just want to clarify(for me and for everyone) that javascript is relatively **static**. I hunger a chance for somebody to correct me. But now seems I lost the chance. – Wilson Luniz Oct 17 '15 at 08:59

0 Answers0