Suppose there is such a script:

<script type="text/javascript" src="theremyjsscript/myjs.js"></script> 

How can src add a date to this so that src looks like this: "http://theremyjsscript/myjs.js?_dc=" + (new Date().getTime())

Maybe somehow it can be done programmatically?

The idea is that every time a script is launched with a new parameter, a new script is launched, and not a script from the cache.

To do this, they do the following type: <script src="myfile.js?version=1.0.0"></script> , and then they change the version and, accordingly, a fresh script will open, but I will not have this opportunity, because I do not have a site, but an application that is installed on a smart TV, and there applications are laid out for months ...

    1 answer 1

    Try this

     var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'http://go.iptvportal.ru/static/portal/standalone.js?_dc=' + (new Date().getTime()); document.getElementsByTagName('head')[0].appendChild(script); 

    Add this code somewhere on the page or in the title.

    • It will not work ... - OPTIMUS PRIME
    • one
      @OPTIMUSPRIME, why? :) - Grundy
    • jsfiddle.net/OPTlMUS/w87zgyfv - o_O and really works. The hitch is to stick the "creating" script at the very end of the page? So that all that is in the script link, worked already on the loaded HTML ... - OPTIMUS PRIME
    • I did right in the head so <script type = "text / javascript" src = "theremyjsscript / myjs.js? _Dc =" + (new Date (). GetTime ())> </ script>, and the medium swore at this post , but everything started and worked. I think this is similar to what you wrote, but I'm not sure that this parameter is added to the link ... Can I somehow check this? Otherwise, I think that the link simply opens without a parameter and as a result there will always be one null parameter - Dmitry Chubarov
    • one
      @ Dmitry Chubarov, in your case, no one will concatenate strings, he doesn’t know how to html , so it won’t work - ThisMan