Web Analytics Made Easy -
StatCounter Reload a js file and nothin else.... - CodingForum

Announcement

Collapse
No announcement yet.

Reload a js file and nothin else....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reload a js file and nothin else....

    Well, i just want to reload my js file nothing else

    thanks for any help
    http://www.bluephoenix.uni.cc/

  • #2
    Ask in the DOM forum about inserting a "new" script tag. It may be possible to insert one and that would cause a copy of the script to be loaded but whether it would use a fresh copy retrieved from the server or the copy already cached is anyone's guess.
    Check out the Forum Search. It's the short path to getting great results from this forum.

    Comment


    • #3
      How I would do it.

      <script id="test" src="test.js" type="text/javascript"></script>
      <script>
      function test()
      {
      scriptBlock=document.getElementById('test');
      scriptBlock.src=scriptBlock.src;
      }</script>

      Comment


      • #4
        I would personally wrap everything except global variable and function declarations in a function, and call that function again if needed, instead of trying to load the script again. There's no guarantee toward whether the file will be called from cache or reloaded at all, and there is no guarantee that the file will be executed again if it is in fact reloaded. Op7 before 7.5 did neither load the file, not execute the script if you wrote it into the file dynamically. Saf1.2 still does neither. Ie5m does only load the file if the script element is written through innerHTML instead of dynamically created.
        liorean <[[email protected]]>
        Articles: RegEx evolt wsabstract , Named Arguments
        Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
        Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

        Comment


        • #5
          migth be me that are wrong here but reload ain't that simply when it calls the file from whatever source it find it at.
          and refresh is when it force downloads a new copy of the requesten file?

          anyway perhaps I should write 'IE6 Scripter ONLY' in my sig

          Comment


          • #6
            Well the thing is that when i just chage the src of the script element it doesnt execute the js file again.

            then i have to reload the whole page.... which takes tooo long in some cases
            http://www.bluephoenix.uni.cc/

            Comment


            • #7
              The src of scripts is read only for practical reasons. You have to create a new script element for it to load anew, in the browsers that does that.
              liorean <[[email protected]]>
              Articles: RegEx evolt wsabstract , Named Arguments
              Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
              Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

              Comment


              • #8
                how?
                http://www.bluephoenix.uni.cc/

                Comment


                • #9
                  For iew, moz and op7.5:
                  Code:
                  var
                      oScript=document.createElement('script');
                  oScript.type='text/javascript';
                  oScript.src=sAddress;
                  document.getElementsByTagName('head').item(0).appendChild(oScript);
                  For iem:
                  Code:
                  var
                      oDiv=document.createElement('div');
                  oDiv.innerHTML='<script type="text/javascript" src="'+sAddress+'"><\/script>';
                  For Saf1.2 (only works on files in the same domain):
                  Code:
                  var
                      oFile=new XMLHttpRequest;
                  oFile.open('GET',sAddress,false);
                  oFile.send('');
                  eval(oFile.responseText);
                  The saf code also works in moz, but may crash the browser in some cases.
                  liorean <[[email protected]]>
                  Articles: RegEx evolt wsabstract , Named Arguments
                  Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
                  Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

                  Comment


                  • #10
                    thanks alot
                    http://www.bluephoenix.uni.cc/

                    Comment

                    Working...
                    X