There’s no way to get rid of the contents of <noscript>
when the user enables Javascript, it will be necessary to do the refresh, and this only the user can do, there is no way around this, except maybe use meta=refresh to reload the page until the user has enabled Javascript, for example:
<noscript>
<!-- faz o refresh de 10 em 10 até que o usuário reabilite o cache -->
<meta http-equiv="refresh" content="10">
Para completa funcionalidade deste site é necessário habilitar o JavaScript.
Aqui estão as <a href="https://www.enable-javascript.com/pt/" target="_blank">
instruções de como habilitar o JavaScript no seu navegador</a>.
</noscript>
One of the reasons for this is because browsers have an input ("import") Javascript execution cycle, for example, if you could run a person-only function enable Javascript then functions like:
document.write
They would fail or over-write the entire page, as this type of functions needs to be executed according to the "flow" rendering DOM (of the page), so that it is necessary to reload the entire page, so that the behavior is as expected as the rendering.
Browsers even come with Javascript disabled?
I want you to understand something, it is practically impossible for a user to disable Javascript, this occurred at the time in IE 4, 5 and Netscape 4, because at the time Javascript was not enabled by default (if I am not mistaken), now really nowadays it is unlikely that the user navigates the sites without Javascript, it is very rare a site that does not depend on such technology, so the user simply could not navigate at all.
If there is any reason why the user has disabled for sure it was intentional, that is even if you put the instructions to enable it probably knows how to do and knows that you will have to give the refresh (F5, Ctrl+R, etc).
So worrying about something like this these days is really unnecessary, because if the user doesn’t want to use javascript enabled, he probably knows what javascript is and has a very good and personal motivation and will probably enable javascript when necessary, of course you can leave the message, but rest assured, if he knows how to disable he will also know how to enable and will know how to refresh after this.
I didn’t understand what you said, do you want when it enables Javascript the page to run the functions without the user having to do the refresh? That’s it?
– Guilherme Nascimento
I want that if javascript is disabled, I want to leave button invisibly until it enable javascript again
– Harry
Man, I think they got you wrong. I understood that you want for example to disappear with a boot/div etc if the guy does not have Javascript enabled, is that it? If it is, what I would do is leave the element already hidden with CSS (display: None), and show it with Javascript as soon as I load the page. This way if the guy has Javascript disabled this function will never be called and the boot will remain hidden.
– user7349055
@user7349055, correct, you were the one who understood the question well, I needed a practical example
– Harry