vars and javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dominique Vermeersch

    #1

    vars and javascript

    I try to do the following:

    <script>
    <!--

    function getStats() {

    nav = navigator.appNa me;
    c = 0;
    if (nav != "Netscape") {
    c = screen.colorDep th;
    } else {
    c = screen.pixelDep th;
    }

    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="JavaS cript"
    src="http://www.yourserver. com/counter.php?kla nt_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
    Tiengebodenstra at 21
    8740 Pittem (Belgium)

    Gsm. +32 (0) 478 958 853
    dominique@trinc h.com
    Brand elevation through smart data and marketing. Drie straffe pijlers zorgen voor doordachte merkcommunicatie.



  • Evertjan.

    #2
    Re: vars and javascript

    Dominique Vermeersch wrote on 21 mrt 2005 in comp.lang.javas cript:
    [color=blue]
    > I try to do the following:
    >
    > <script>[/color]

    <script type='text/javascript'>
    [color=blue]
    > <!--[/color]

    Outdated for the last 5 years
    [color=blue]
    >
    > function getStats() {
    >
    > nav = navigator.appNa me;
    > c = 0;[/color]

    not usefull since it will be reassigned anyway
    [color=blue]
    > if (nav != "Netscape") {
    > c = screen.colorDep th;
    > } else {
    > c = screen.pixelDep th;
    > }
    >
    > 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;
    > }
    > //-->[/color]

    same
    [color=blue]
    > </script>
    >
    > <script language="JavaS cript"[/color]

    outdated, use:

    type='text/javascript'
    [color=blue]
    > src="http://www.yourserver. com/counter.php?kla nt_id=62&' + stats[/color]

    This does not work.
    There is no reason for javascript to be executed in a src declaration.
    Echt niet!
    [color=blue]
    > +'"></script>
    >
    > But the stats var is not put through to the second script ...
    > Is there another way to achieve this?[/color]

    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.

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)

    Comment

    • Hal Rosser

      #3
      Re: vars and javascript

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


      Comment

      Working...