Forum Moderators: open

Message Too Old, No Replies

Help modifying javascript please

Page code needs to show all counts but register only one

         

houseofstrauss

11:04 am on Oct 4, 2003 (gmt 0)

10+ Year Member



Below is my page code for a users online script. I want each one of my pages to SHOW the count, but only 1 specific page to REGISTER a count. How do I modify this page code to ignore everything except one particular page? let's say '../chat.html'

Thank-you, Richard

<script language="JavaScript">
<!--
var url = "http://url/to_CGI_BIN/online.cgi";
if (document.title == "") {
title = "Unknown";
} else {
title = document.title;
}
document.write("<scr"+"ipt lan"+"guage='Jav"+"aScr"+"ipt' sr"+"c='"+url+"?title="+title+"'>");
document.write("</scr"+"ipt>");
//-->
</script>

tedster

6:24 pm on Oct 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Richard, I'm not sure what results you are aiming for - but there's nothing in this javascript that would refer to a different page that I can see. Nothing in there about counts, showing or registering.

The issue you face probably involves other code - perhaps your cgi code, or perhaps other javascript.

MonkeeSage

7:01 pm on Oct 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If online.cgi is the counter, you can do it like this...

<script type="text/javascript"> 
<!--
var url = "http://url/to_CGI_BIN/online.cgi";

// get filename
var filename = window.location.href;

// check for "chat.htm" in filename
if (filename.search(/chat\.htm/i) > -1) {

// get the title of the page
var title = document.title;
if (title == "") {
title = "Unknown";
}

// create the new script element
var scr = document.createElement("script");
scr.type= "text/javascript";

// set its src
scr.src = url + "?title=" + title;

// append it to the head element
var head = document.getElementsByTagName("head")[0];
head.appendChild(scr);
}
//-->
</script>

...only if the filename has "chat.htm" somewhere in it will the script element be inserted that calls online.cgi.

Jordan

houseofstrauss

7:22 pm on Oct 4, 2003 (gmt 0)

10+ Year Member



Thanks for the above comments

...only if the filename has "chat.htm" somewhere in it will the script element be inserted that calls online.cgi.
is just what I am looking for . Ill try this code

Thanks