Closed Thread Icon

Topic awaiting preservation: refreshing script Pages that link to <a href="https://ozoneasylum.com/backlink?for=8441" title="Pages that link to Topic awaiting preservation: refreshing script" rel="nofollow" >Topic awaiting preservation: refreshing script\

 
Author Thread
Koenie
Nervous Wreck (II) Inmate

From: Leiden, the Netherlands
Insane since: Dec 2002

posted posted 12-17-2002 16:39

Hi, I'm new and my name is Koenie. Hi all.

I've got this external .js file and I want the content of it to refresh during the view of the page which includes the .js file, because server side scripts edit the content of the .js file during the view of the page.
I tried the following code, but it doesn't work. (wpName, wpMember, wpDate and wpMsg are arrays stored in the .js file. The ref() function is just there to make the 'document.getElementById()' shorter.)


code:
function startRefresh() {
delete wpName;
delete wpMember;
delete wpDate;
delete wpMsg;
var libRef = ref('messages');
var head = document.getElementsByTagName('head').item(0);
if (libRef) head.removeChild(libRef);
var shibbyRef = document.createElement('script');
shibbyRef.type = 'text/javascript';
shibbyRef.id = 'messages';
head.appendChild(shibbyRef);
ref('messages').src = 'messages.js';
ref('messages').onreadystatechange = endRefresh;
}

function endRefresh() {
if (ref('messages').readyState == 'loaded') {goToPage(1)}
}

function ref(id) {var obj = document.getElementById(id); return obj}



Can anyone help???

Thanks in advance, Koenie

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 12-17-2002 17:57

I'm sorry, Koenie, but I'm not sure I understand what you're trying to do. It's early and I may just be too sleepy

And welcome!

. . : slicePuzzle

Koenie
Nervous Wreck (II) Inmate

From: Leiden, the Netherlands
Insane since: Dec 2002

posted posted 12-17-2002 19:25

Well, I included a .js file (<script type="text/javascript" src="messages.js"></script> and the contents of it are being edited during the page view of a visitor. I want to refresh the content of that script without having to refresh the total page.

And thanks for the welcome :P

Koenie

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-17-2002 19:26

You should be able to dynamically update data via the DOM by dynamically updating a JS file.

Bratta's got a tute here



.:[ Never resist a perfect moment ]:.

Koenie
Nervous Wreck (II) Inmate

From: Leiden, the Netherlands
Insane since: Dec 2002

posted posted 12-17-2002 20:34

Yeah, that's the thing I used. But I need to know when the script has loaded, to go on with the processing.

Any suggestions?

Koenie

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-17-2002 21:57

sure just have the script set a variable to true once it's loaded.



.:[ Never resist a perfect moment ]:.

MisterEd
Neurotic (0) Inmate
Newly admitted

From: bainbridge island WA usa
Insane since: Dec 2002

posted posted 12-31-2002 23:17

If I understand what you are saying, an external *.js file is changing
in real time. If so, you have a big problem because your visitors'
browsers have already cached it. (Many browsers will cache *.js file
even when caching is turned off!) If the clients don't refresh the
page there's no way to force the *.js file to reload.

Depending on local preferences, a browser may not even consider
looking for changes to js files until next visit.

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 01-01-2003 01:19

The talking horse is right, you can't delete the script and replace it exactly.
Why not just add another one?
Or do what I do most of the time, and that is refresh iFrames and use the scripts inside of those.

Here's what i use when setting new locations or refreshing iframes.
Should work the same for you.
I use setTimeouts and keep resetting until the page location matches what i want.

code:
function rand(x) { return Math.floor(x*Math.random()); }

/* end general purpose functions
begin app-specific functions
*/
function locChg() {
if(!spotRe) {
//spofLoc is String of original location
//here i add a random number to it
spotHref = spofLoc+"?blah="+rand(868);
spof.location.replace(spotHref); //send to new location
spotRe = window.setTimeout("locChg()",300);
}else if(spof.location != spotHref) {
spotRe = window.setTimeout("locChg()",300);
}else {
spotRe=0;
//do all your greatness here.
}
}

I'm unfamiliar with that .onreadystatechange property, is it IE specific?
Good luck.

« BackwardsOnwards »

Show Forum Drop Down Menu