|
|
 |
 |
 |
 |
Javascript / Client Side Development
|
 |
 |
 |
 |
 |
 |
 |
 |
Reload all included javascript src
Hi everyone, is there a way to reload all external scripts each 60 sec? By external I mean on <script src="status.php" type="text/javascript"></script> so lets say that I have several includes of scripts in a HTML page and is there a way to reload it each 60 sec? I know I can do this by AJAX, but can it be done this way?
Hrvoje Vencl said the following on 5/17/2007 4:21 PM: > Hi everyone, > is there a way to reload all external scripts each 60 sec? By external > I mean on > <script src="status.php" type="text/javascript"></script> > so lets say that I have several includes of scripts in a HTML page and > is there a way to reload it each 60 sec? I know I can do this by AJAX, > but can it be done this way?
Yes. And, I can do it more reliably than AJAX can because AJAX would require the same technique but adds the overhead of an XHR request that I don't need to do. -- Randy Chance Favors The Prepared Mind comp.lang.javascript FAQ - http://jibbering.com/faq/index.html Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Hi Randy, can you write here a simple script that would do that job? In that called script I only use: document.write('some html code here'); Thanks!
Hrvoje Vencl said the following on 5/19/2007 8:07 AM: > Hi Randy,
Umm, hi. > can you write here a simple script that would do that job?
To do what job? Quote what you are replying to so people know what you are referring to. > In that called script I only use: > document.write('some html code here');
Executing that script one time after the page loads would be the limit. After the page loads, if you document.write to the page then it replaces the current page. So, the only thing that would be in your page is the html in the string you wrote. If you want to be able to continuously execute the script without destroying the current page you need to use something like DynWrite from the FAQ. Then, wrap it in a function and simply call the function, end of problems. No need to try to keep "reloading all included script files". Just to answer the question, search the archives for loadJSFile and you can find many different variations of a function that will load .js files on the fly. You would simply have to loop through the script tags, pick up the src attribute, and loadJSFile load the file again. -- Randy Chance Favors The Prepared Mind comp.lang.javascript FAQ - http://jibbering.com/faq/index.html Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Thanks, but I think I will re-write it to ajax, as it will take less time for me to do it like that. Randy Webb je napisao/la:
> Hrvoje Vencl said the following on 5/19/2007 8:07 AM: > > Hi Randy, > Umm, hi. > > can you write here a simple script that would do that job? > To do what job? Quote what you are replying to so people know what you > are referring to. > > In that called script I only use: > > document.write('some html code here'); > Executing that script one time after the page loads would be the limit. > After the page loads, if you document.write to the page then it replaces > the current page. So, the only thing that would be in your page is the > html in the string you wrote. If you want to be able to continuously > execute the script without destroying the current page you need to use > something like DynWrite from the FAQ. Then, wrap it in a function and > simply call the function, end of problems. No need to try to keep > "reloading all included script files". > Just to answer the question, search the archives for loadJSFile and you > can find many different variations of a function that will load .js > files on the fly. You would simply have to loop through the script tags, > pick up the src attribute, and loadJSFile load the file again. > -- > Randy > Chance Favors The Prepared Mind > comp.lang.javascript FAQ - http://jibbering.com/faq/index.html > Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Hrvoje Vencl said the following on 5/20/2007 3:18 PM: > Thanks, > but I think I will re-write it to ajax,
If you want to make it harder than it has to be, that is your choice. > as it will take less time for me to do it like that.
I doubt it will take less time as you are going to have to do some things either way and the ajax approach adds more to it. Answer:It destroys the order of the conversation Question: Why? Answer: Top-Posting. Question: Whats the most annoying thing on Usenet? -- Randy Chance Favors The Prepared Mind comp.lang.javascript FAQ - http://jibbering.com/faq/index.html Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
I already use AJAX on site so this will only need to copy/paste some code from 'js' do 'ajax' display. Thanks anyway. Venki Randy Webb je napisao/la:
> Hrvoje Vencl said the following on 5/20/2007 3:18 PM: > > Thanks, > > but I think I will re-write it to ajax, > If you want to make it harder than it has to be, that is your choice. > > as it will take less time for me to do it like that. > I doubt it will take less time as you are going to have to do some > things either way and the ajax approach adds more to it. > Answer:It destroys the order of the conversation > Question: Why? > Answer: Top-Posting. > Question: Whats the most annoying thing on Usenet? > -- > Randy > Chance Favors The Prepared Mind > comp.lang.javascript FAQ - http://jibbering.com/faq/index.html > Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Hrvoje Vencl said the following on 5/21/2007 8:21 AM: > I already use AJAX on site so this will only need to copy/paste some > code from 'js' do 'ajax' display. Thanks anyway.
Considering that you can't interleave your replies properly even when explicitly shown how to do it, I doubt you are in a position to even know whether it is simple. I know, beyond any doubt, that the use of Ajax to do what you asked about is more work than what I suggested because you are going to have to do what I suggested to get the ajax part to work. -- Randy Chance Favors The Prepared Mind comp.lang.javascript FAQ - http://jibbering.com/faq/index.html Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
|
 |
 |
 |
 |
|