Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3998696
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:33:33+00:00 2026-05-20T07:33:33+00:00

I have a web page with a Javascript file added dynamically. After changing the

  • 0

I have a web page with a Javascript file added dynamically.
After changing the script (adding allert or smth like this) I reload the page, and push a trigger button for adding the script, but the browser uses the old one (chached).
Tried it in chrome and IE.
Other scripts (that are not added dynamically) reload well.

Here is the function that loads the script:

function addScript (s)
{
    script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = s;
    document.getElementsByTagName('head')[0].appendChild(script);
    script.onload=function () 
    {
        switch (s)
        {
            case 'some address':
                 functionInTheNewFile(); break; 
            default: break; 
        }
    };
}

What is wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:33:33+00:00Added an answer on May 20, 2026 at 7:33 am

    If it is an external script caching, append the current date and time to the end of the script. IE:

    var nowDate = new Date();
    script.src = s + "?nocache=" + nowDate.getTime();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added jquery js file to a web page in .NET 1.1 web
I have an asp.net web page written in C#. Using some javascript I popup
I'm writing a web page in ASP.NET. I have some JavaScript code, and I
I have a one page web application, which means alot of javascript. External scripts
I have this script protovis : <script type=text/javascript+protovis> var w = 600; var h
I have a web page that pulls in several javascript files in the HEAD
I have several elements in my web page generated by JavaScript. Here's an example
We have some html that looks like this: <form id=MyUserControl runat=server method=post> <script language=javascript
I am working on a web page that pulls an external javascript file that
Let's imagine a web page page needing to load a javascript file (i.e. my.js

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.