vars and javascript

  • Thread starter Dominique Vermeersch
  • Start date
D

Dominique Vermeersch

I try to do the following:

<script>
<!--

function getStats() {

nav = navigator.appName;
c = 0;
if (nav != "Netscape") {
c = screen.colorDepth;
} else {
c = screen.pixelDepth;
}

s = screen.width+" X "+screen.height;
ref = escape(document.referrer);
url = escape(document.URL);

var stats = "referrer=" + ref + "&get_url=" + url + "&screen=" + s +
"&color=" + c;
return stats;
}
//-->
</script>

<script language="JavaScript"
src="http://www.yourserver.com/counter.php?klant_id=62&' + stats
+'"></script>

But the stats var is not put through to the second script ...
Is there another way to achieve this?

Kind regards,

Dom.


--
--
Trinch | New Media Services

Dominique Vermeersch
Tiengebodenstraat 21
8740 Pittem (Belgium)

Gsm. +32 (0) 478 958 853
(e-mail address removed)
http://www.trinch.com
 
E

Evertjan.

Dominique Vermeersch wrote on 21 mrt 2005 in comp.lang.javascript:
I try to do the following:

<script>


Outdated for the last 5 years
function getStats() {

nav = navigator.appName;
c = 0;

not usefull since it will be reassigned anyway
if (nav != "Netscape") {
c = screen.colorDepth;
} else {
c = screen.pixelDepth;
}

s = screen.width+" X "+screen.height;
ref = escape(document.referrer);
url = escape(document.URL);

var stats = "referrer=" + ref + "&get_url=" + url + "&screen=" + s +
"&color=" + c;
return stats;
}
//-->
same

</script>

<script language="JavaScript"

outdated, use:

type='text/javascript'

This does not work.
There is no reason for javascript to be executed in a src declaration.
Echt niet!
+'"></script>

But the stats var is not put through to the second script ...
Is there another way to achieve this?

Natuurlijk, gebruik serverside code, blijkbaar gebruik je php, waar ik
niets van weet, maar in ASP is het makkelijk.

Reload the whole page after posting the stats to serverside.
 
H

Hal Rosser

Declare the var outside of a function, then you can use it in any function
on the page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top