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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested Script Tags? Help!

Status
Not open for further replies.

marmablue

Technical User
Dec 27, 2001
10
0
0
GB
Okay, here's the problem. I have a small part of my page that displays the number of users on my forums by using a small Javascript code. This is:

<script src=&quot;../bbs/cgi-bin/yabb/YaBB.cgi?action=printwhoisonline&group=guests></script>

Currently I've put this on a separate frame, using META refresh to refresh it every few seconds. Problem is, that looks ugly - I only want the text to refresh not the whole frame. So I came up with this based on another code I saw:

There are
<script>
function refresh() {
document.write(&quot;<script src=&quot;../bbs/cgi-bin/yabb/YaBB.cgi?action=printwhoisonline&group=guests&quot;></script>&quot;);
window.setTimeout(&quot;refresh();&quot;, 100);
}
window.onload = refresh;
</SCRIPT>
other users online.</td>

Unfortunatley, it doesn't like the <script> tags nested inside the document.write, and it treats the </script> inside the document.write as if it was closing the refresh script as well as the one I want.

Any ideas as to how I can fix this? Or another way of getting a script to refresh every few seconds?

Any help much appreciated,
Moon Shadow
Official Javascript Newbie
moonshadow@talk21.com
 
I've never had to document.write the <script. tags, but have seen this question asked on different forums. the answer is:
document.write(&quot;<scr&quot; + &quot;ipt src=&quot;../bbs/cgi-bin/yabb/YaBB.cgi?action=printwhoisonline&group=guests&quot;></scr&quot; + &quot;ipt>&quot;); --------------------------------------------------
Goals are dreams with deadlines
 
and I have just thought of another anser I've seen out there:
document.write(&quot;<s\cript src=&quot;../bbs/cgi-bin/yabb/YaBB.cgi?action=printwhoisonline&group=guests&quot;></s\cript>&quot;);

It is claimed that the \ would work placed
anywhere in the word script except just
before the s or r as \s and \r mean something

HTH --------------------------------------------------
Goals are dreams with deadlines
 
I think the problem is that you have 2 sets of double quotes in there without adding a + sign, Change it to the following:

<script>
function refresh() {
document.write(&quot;<script src=../bbs/cgi-bin/yabb/YaBB.cgi?action=printwhoisonline&group=guests></script>&quot;);
window.setTimeout(&quot;refresh();&quot;, 100);
}
window.onload = refresh;
</SCRIPT>


I just got rid of the 2nd set of quotes. You can do this since you don't need &quot;&quot; double quotes around a pathname that contains no spaces.

If you want the quotes in there just put a forward slash in front of the 2nd set (\&quot;some text\&quot;). Rocco is the BOY!!

M O T I V A T E!
 
Thanks valeriav! Your suggestion works fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top