Is it possible to programmatically reload JavaScript files in mobile browsers on page refresh?

StackOverflow https://stackoverflow.com/questions/22383833

Pergunta

I am developing a web application and while working on a desktop, I am used to force reloading pages using Ctrl-F5 in the browser to clear any cached copies when I make changes to javascript files.

I am not able to do that in mobile browsers since they don't have a Ctrl-F5 or forced reload feature. I want to refrain from using version numbers in the javascript's querystrings to force a reload files whenever I make changes.

Is there any client-side or server-side way to force a mobile browser to refresh javascripts when reloading a webpage?

Foi útil?

Solução

Sure. The following method can be used to load in a JavaScript file programmatically.

function LoadJsFile(jsUrl) 
{
    var script = document.createElement("script");
    script.setAttribute("type", "text/javascript");
    script.setAttribute("src", request);
    document.body.appendChild(script);
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top