Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DIV reloading using Javascript Possible ?

Status
Not open for further replies.

stefzodiak

Programmer
Jun 17, 2003
3
CA
Hello everyone,

Okay, I have probably a very strange question, so
please bear with me :)

I generate a HTML file in perl, but i would like a
certain DIV to reload automatically (it will be an
update of the number of open tasks on the order system)

I know that I can refresh the entire page by doing
something like:

<script language=&quot;javascript&quot;>window.setTimeout(&quot;document.reload.submit();&quot;,3000);</script>

However, can I jst refresh a named DIV tag in some
way similiar ? It would be nice if i could specify another
location to 'refresh' the DIV with (sort of similiar
to the location function in javascript).

Any ideas ? Pointers ?

(i am this close to writing it in Flash, its gotten that bad :)

Thanks
Stef
 
you could do this....
document.getElementById('divID').innerHTML=&quot;blahblahblah&quot;;
... but that would take a lot of typing.... You could make a variable in the Javascript with HTML tags and stuff... and then every time you want to reload it, you could just get the element and make the innerHTMl the variable. Hope that helps.

Later,
Greelmo
 
Hello there,

Well, i tried to setup a timeout on the window, so
that it will auto-reload, but no joy. Here is what i
tried:

Code:
<script language=&quot;javascript&quot;>window.setTimeout('document.getElementById('Content').innerHTML=&quot;<HTML><BODY><BR><BR>Hello...<BR><BODY></HTML>&quot;;',3000);</script>

but, no luck. of course, timeout's work jst fine with
reload.submit(), so is this a limitation of javascript
perhaps ?

Btw, if its any point of concern, i use Netscape
on this machine (its a linux machine, so IE isnt going
to work for me, so sorry if this is a Netscape problem ;)

Many thanks
Stef
 
i don't think it's a netscape thing... try...
<script type=&quot;text/javascript&quot;>
var rfrshme=setTimeout(&quot;document.getElementById('content').innerHTML='<font size=7 color=red>Hello</font>';&quot;, 5000);
</script>

Later,
Greelmo
 
In IE, i'd use a hidden iFrame, with an onLoad script to copy it's page HTML to the parent.DivID.innerHTML, then setTimeout(document.reload(),10000) in the iFrame document.

...in Netscape, I think you're barking up a dead horse.

I don't think anything in Netscape has it's own Source, except frames.
 
hello again,

funnily enough, i got it working, although only in netscape, i assume as its probably not IE-friendly,
although any pointers on that would be highly appreciated
(i REALLY dont know the differences between the two)

in the 'parent' page, i do this:

<iframe id=&quot;myFrame&quot; frameborder=&quot;0&quot; vspace=&quot;0&quot; hspace=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; width=&quot;100%&quot; src=&quot;/work/Unified/stef_msg.html&quot; scrolling=&quot;no&quot; style=&quot;overflow:visible&quot;></iframe>
<script language=&quot;javascript&quot;>setInterval(&quot;document.getElementById('myFrame').src='/work/Unified/stef_msg.html'&quot;, 10000);</script>


and then in the file /work/Unified/stef_msg.html i have:

<HTML>
<BODY>
<script language=&quot;Javascript&quot;>
function update_me() {
top.document.getElementById('workbasketBottom').innerHTML='<font size=7 color=blue>here</font>'
}
</script>
<script language=&quot;Javascript&quot;>update_me()</script>
</BODY>
</HTML>


This may seem like a lot of work, but the beauty here is that the html file is regenerated every 5 seconds by a perl
background process on the server. That way it allows me to
'somewhat' update html without reloading the entire page or
resorting to Flash/SWF or RealPlayer (not everyone has Flash
and it is positively a pain sometimes on non-windows machines :)

So, thats the long and short of it. Thank you for the help and if anyone has any advice on how to make it IE friendly (i checked and the above doesnt work for some
reason) that would be great :)

Regards
Stef
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top