need help understanding this code.

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

    need help understanding this code.

    Hi,

    I've been trying to figure out this javascript code used here (this code is
    used for supplying browser info to a tracking company):

    In particular I'm trying to understand this line:
    EXd=document;EX w?"":EXw="na";E Xb?"":EXb="na" ;
    and this one: EXd.write("<img
    src=\"http://t0.extreme-dm.com","/0.gif?tag=abc&j =y&srw="+EXw+"& srb="+EXb+"&
    ","l="+escape(E Xd.referrer)+"\ " height=1 width=1>");//-->

    Why do they have a variable j=y defined? There is no 'j' variable defined
    in the code.

    If I modify the http://t0.extreme-dm.com and send the results to my ASP page
    and use Querystrings to see what the values are, I only get the Screen width
    and colour depth values. The referrer information is not showing. I also
    don't understand how they can extract users country domain from this code.

    Thanks
    Tristan



    ----------- Complete code below ---------------


    <a target="_top" href="http://t.extreme-dm.com/?login=abc"> <img
    src="http://u1.extreme-dm.com/i.gif" height=2
    border=0 width=2 alt=""></a>
    <script language="javas cript1.2"><!--
    EXs=screen;EXw= EXs.width;navig ator.appName!=" Netscape"?
    EXb=EXs.colorDe pth:EXb=EXs.pix elDepth;//-->
    </script>
    <script language="javas cript"><!--
    EXd=document;EX w?"":EXw="na";E Xb?"":EXb="na" ;
    EXd.write("<img src=\"http://t0.extreme-dm.com",
    "/0.gif?tag=abc&j =y&srw="+EXw+"& srb="+EXb+"&",
    "l="+escape(EXd .referrer)+"\" height=1 width=1>");//-->
    </script>
    </p>
    <noscript><im g height=1 width=1 alt=""
    src="http://t0.extreme-dm.com/0.gif?tag=abc&j =n"></noscript>


  • Bryan Field-Elliot

    #2
    Re: need help understanding this code.

    That's some dense shit, dude. But seriously I don't think you quoted all
    the relevent code to make heads or tails of this, looks like you only
    quoted the last line or two.

    These two statements:

    EXw?"":EXw="na" ;
    EXb?"":EXb="na" ;

    All they do is, if EXw and EXb are null, then set them to "na" (as in
    Not Available?). But it must be somewhere earlier in the code where they
    are setting EXw and EXb to initial values in the first place.

    In regards to the "j=y" statement; the way you've quoted the code, the
    variable j (and value y) are used entirely on the server. There is no
    client-side javascript here with a variable j and value of y. You need
    to look on the server side script (if you have it) to find out what the
    "j=y" is all about.

    Did you inherit this code from another developer, or are you trying to
    *ahem* learn from some other site's techniques?

    --

    Bryan Field-Elliot




    Elmbrook wrote:[color=blue]
    > Hi,
    >
    > I've been trying to figure out this javascript code used here (this code is
    > used for supplying browser info to a tracking company):
    >
    > In particular I'm trying to understand this line:
    > EXd=document;EX w?"":EXw="na";E Xb?"":EXb="na" ;
    > and this one: EXd.write("<img
    > src=\"http://t0.extreme-dm.com","/0.gif?tag=abc&j =y&srw="+EXw+"& srb="+EXb+"&
    > ","l="+escape(E Xd.referrer)+"\ " height=1 width=1>");//-->
    >
    > Why do they have a variable j=y defined? There is no 'j' variable defined
    > in the code.
    >
    > If I modify the http://t0.extreme-dm.com and send the results to my ASP page
    > and use Querystrings to see what the values are, I only get the Screen width
    > and colour depth values. The referrer information is not showing. I also
    > don't understand how they can extract users country domain from this code.
    >
    > Thanks
    > Tristan
    > www.backpackpro.com
    >
    >
    > ----------- Complete code below ---------------
    >
    >
    > <a target="_top" href="http://t.extreme-dm.com/?login=abc"> <img
    > src="http://u1.extreme-dm.com/i.gif" height=2
    > border=0 width=2 alt=""></a>
    > <script language="javas cript1.2"><!--
    > EXs=screen;EXw= EXs.width;navig ator.appName!=" Netscape"?
    > EXb=EXs.colorDe pth:EXb=EXs.pix elDepth;//-->
    > </script>
    > <script language="javas cript"><!--
    > EXd=document;EX w?"":EXw="na";E Xb?"":EXb="na" ;
    > EXd.write("<img src=\"http://t0.extreme-dm.com",
    > "/0.gif?tag=abc&j =y&srw="+EXw+"& srb="+EXb+"&",
    > "l="+escape(EXd .referrer)+"\" height=1 width=1>");//-->
    > </script>
    > </p>
    > <noscript><im g height=1 width=1 alt=""
    > src="http://t0.extreme-dm.com/0.gif?tag=abc&j =n"></noscript>
    >
    >[/color]

    Comment

    • Hywel Jenkins

      #3
      Re: need help understanding this code.

      In article <C3Idb.4320$tv1 .540589@news02. tsnz.net>,
      elmbrook@paradi se.nospam.net.n z says...[color=blue]
      > Hi,
      >
      > I've been trying to figure out this javascript code used here (this code is
      > used for supplying browser info to a tracking company):
      >
      > In particular I'm trying to understand this line:
      > EXd=document;[/color]

      Set EXd to the "document" object;
      [color=blue]
      > EXw?"":EXw="na" ;[/color]

      If EXw is empty, set it to "na".
      [color=blue]
      > EXb?"":EXb="na" ;[/color]

      If EXb is empty, set it to "na".
      [color=blue]
      > and this one: EXd.write("<img
      > src=\"http://t0.extreme-dm.com","/0.gif?tag=abc&j =y&srw="+EXw+"& srb="+EXb+"&
      > ","l="+escape(E Xd.referrer)+"\ " height=1 width=1>");//-->[/color]

      That writes out an image using the values the script has just assigned.

      [color=blue]
      > Why do they have a variable j=y defined? There is no 'j' variable defined
      > in the code.[/color]

      The "j" isn't used in the code you've given here - it may be used in the
      server-side script that servers up the image, though. It's part of the
      URL, not part of the JavaScript. I imagine that other users may have
      "j" set to something else, otherwise there'd be no point having it.

      [color=blue]
      > If I modify the http://t0.extreme-dm.com and send the results to my ASP page
      > and use Querystrings to see what the values are, I only get the Screen width
      > and colour depth values.[/color]

      Perhaps your ASP that's trying to get the values is broken.

      [color=blue]
      > The referrer information is not showing. I also
      > don't understand how they can extract users country domain from this code.[/color]

      The won't extract the user's country domain from that code. They'll
      have their server-side code do it by tracking the remote IP address (ie.
      the site visitor's address) from which the request is made. It's rather
      inaccurate, though.

      --
      Hywel I do not eat quiche


      Comment

      • Ivo

        #4
        Re: need help understanding this code.

        "Elmbrook" <elmbrook@parad ise.nospam.net. nz> wrote in message
        news:C3Idb.4320 $tv1.540589@new s02.tsnz.net...[color=blue]
        > In particular I'm trying to understand this line:
        > EXd=document;EX w?"":EXw="na";E Xb?"":EXb="na" ;[/color]

        EXw?"":EXw="na"
        is short for: if EXw has not been assigned a value in the preceding
        javascript1.2 block, give it a value of "na".
        [color=blue]
        > and this one: EXd.write("<img
        >[/color]
        src=\"http://t0.extreme-dm.com","/0.gif?tag=abc&j =y&srw="+EXw+"& srb="+EXb+"&[color=blue]
        > ","l="+escape(E Xd.referrer)+"\ " height=1 width=1>");//-->
        >
        > Why do they have a variable j=y defined? There is no 'j' variable defined
        > in the code.[/color]
        So what? Do you see tag, srw, srb anywhere else? This is where j gets
        defined. Think of y as a string of length 1. It probably means "javascript
        enabled=yes". Look in the noscript tag where you 'll find "j=n".


        Comment

        • Spamless

          #5
          Re: need help understanding this code.

          In article <C3Idb.4320$tv1 .540589@news02. tsnz.net>, Elmbrook wrote:[color=blue]
          > Hi,
          >
          > I've been trying to figure out this javascript code used here (this code is
          > used for supplying browser info to a tracking company):
          >
          > In particular I'm trying to understand this line:
          > EXd=document;EX w?"":EXw="na";E Xb?"":EXb="na" ;[/color]

          This uses

          A?B:C

          If A is true, then do B, otherwise do C.

          If A is not a boolean test, but some variable,
          then A? just checks if A is defined.

          So, A?B:C does B if A is defined, otherwise it does C.

          EXw?"":EXw="na"

          Well, the author REALLY WANTS EXw to be defined and if
          it is not defined he wants to define it a the string
          "na" (not available or not applicabe)..

          EXw ? "" : EXw="na"

          IS EXw defined? If, nothing Otherwise define it
          leave it alone as "na"
          [color=blue]
          > and this one: EXd.write("<img
          > src=\"http://t0.extreme-dm.com","/0.gif?tag=abc&j =y&srw="+EXw+"& srb="+EXb+"&
          > ","l="+escape(E Xd.referrer)+"\ " height=1 width=1>");//-->[/color]

          That creates a URL:

          "0.gif?tag=abc& j=y&srw..."
          [color=blue]
          > Why do they have a variable j=y defined? There is no 'j' variable defined
          > in the code.[/color]

          The "j" is inside the string. It is not a JavaScript variable, but just
          text. IF that works (the document.write, sicne EXd is the document,
          then it must have been written by JavaScript. I would guess the tag
          will be interpreted as the author (when he checks his web logs and
          sees this) as JavaScript IS enabled (j=y) (or else this won't even
          be written to the documnet).

          Comment

          • Elmbrook

            #6
            Re: need help understanding this code.

            I'm trying to figure out how I can record the statistics of the visitors to
            my website, where they came from etc and send this to an ASP page.

            Are there Javascripts available for recording, referreal, domain etc?

            Thanks for your help


            "Bryan Field-Elliot" <bryan@netmeme. org> wrote in message
            news:IhIdb.4551 17$Oz4.260098@r wcrnsc54...[color=blue]
            > That's some dense shit, dude. But seriously I don't think you quoted all
            > the relevent code to make heads or tails of this, looks like you only
            > quoted the last line or two.
            >
            > These two statements:
            >
            > EXw?"":EXw="na" ;
            > EXb?"":EXb="na" ;
            >
            > All they do is, if EXw and EXb are null, then set them to "na" (as in
            > Not Available?). But it must be somewhere earlier in the code where they
            > are setting EXw and EXb to initial values in the first place.
            >
            > In regards to the "j=y" statement; the way you've quoted the code, the
            > variable j (and value y) are used entirely on the server. There is no
            > client-side javascript here with a variable j and value of y. You need
            > to look on the server side script (if you have it) to find out what the
            > "j=y" is all about.
            >
            > Did you inherit this code from another developer, or are you trying to
            > *ahem* learn from some other site's techniques?
            >
            > --
            >
            > Bryan Field-Elliot
            > http://netmeme.org
            >
            >
            >
            > Elmbrook wrote:[color=green]
            > > Hi,
            > >
            > > I've been trying to figure out this javascript code used here (this code[/color][/color]
            is[color=blue][color=green]
            > > used for supplying browser info to a tracking company):
            > >
            > > In particular I'm trying to understand this line:
            > > EXd=document;EX w?"":EXw="na";E Xb?"":EXb="na" ;
            > > and this one: EXd.write("<img
            > >[/color][/color]
            src=\"http://t0.extreme-dm.com","/0.gif?tag=abc&j =y&srw="+EXw+"& srb="+EXb+"&[color=blue][color=green]
            > > ","l="+escape(E Xd.referrer)+"\ " height=1 width=1>");//-->
            > >
            > > Why do they have a variable j=y defined? There is no 'j' variable[/color][/color]
            defined[color=blue][color=green]
            > > in the code.
            > >
            > > If I modify the http://t0.extreme-dm.com and send the results to my ASP[/color][/color]
            page[color=blue][color=green]
            > > and use Querystrings to see what the values are, I only get the Screen[/color][/color]
            width[color=blue][color=green]
            > > and colour depth values. The referrer information is not showing. I[/color][/color]
            also[color=blue][color=green]
            > > don't understand how they can extract users country domain from this[/color][/color]
            code.[color=blue][color=green]
            > >
            > > Thanks
            > > Tristan
            > > www.backpackpro.com
            > >
            > >
            > > ----------- Complete code below ---------------
            > >
            > >
            > > <a target="_top" href="http://t.extreme-dm.com/?login=abc"> <img
            > > src="http://u1.extreme-dm.com/i.gif" height=2
            > > border=0 width=2 alt=""></a>
            > > <script language="javas cript1.2"><!--
            > > EXs=screen;EXw= EXs.width;navig ator.appName!=" Netscape"?
            > > EXb=EXs.colorDe pth:EXb=EXs.pix elDepth;//-->
            > > </script>
            > > <script language="javas cript"><!--
            > > EXd=document;EX w?"":EXw="na";E Xb?"":EXb="na" ;
            > > EXd.write("<img src=\"http://t0.extreme-dm.com",
            > > "/0.gif?tag=abc&j =y&srw="+EXw+"& srb="+EXb+"&",
            > > "l="+escape(EXd .referrer)+"\" height=1 width=1>");//-->
            > > </script>
            > > </p>
            > > <noscript><im g height=1 width=1 alt=""
            > > src="http://t0.extreme-dm.com/0.gif?tag=abc&j =n"></noscript>
            > >
            > >[/color]
            >[/color]


            Comment

            • Lasse Reichstein Nielsen

              #7
              Re: need help understanding this code.

              Spamless <Spamless@Nil.n il> writes:
              [color=blue]
              > This uses
              >
              > A?B:C
              >
              > If A is true, then do B, otherwise do C.[/color]
              [color=blue]
              > If A is not a boolean test, but some variable,
              > then A? just checks if A is defined.[/color]

              That is not strictly correct.

              If A is an undeclared variable, then "A?B:C" fails with an "undeclared
              variable". If A is a declared variable, then its value is converted to
              a boolean (as by the Boolean function). The values that are converted
              to false are: 0, NaN, undefined, null, "" (empty string), and false
              itself.

              So, if A is defined but has the value 0, the "else" branch is still
              used.
              [color=blue]
              > EXw?"":EXw="na"[/color]

              personally, I would have written:

              EXw = EXw || "na";

              It has the same effect, is easier to read (IMHO), and is even shorter.

              What he really means is
              if(!EXw)EXw="na ";
              but that is one charater longer.

              Where "if" is a statement that selects one of two *statements* based
              on a conditional expression, the ?:-operator is an expression that
              selects one of two expressions based on a condition. The original
              author uses it as a statement, which *I* think is bad style.

              /L
              --
              Lasse Reichstein Nielsen - lrn@hotpop.com
              Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
              'Faith without judgement merely degrades the spirit divine.'

              Comment

              • Bryan Field-Elliot

                #8
                Re: need help understanding this code.

                All this stuff should be done server-side (e.g. ASP, JSP, Perl,
                whatever), rather than client-side (e.g. Javascript). From the server,
                you should have access to the referring URL and the IP address of the
                client (and from there, you can find their domoain). All this and more
                in the HTTP headers. No client-side Javascript required (or even useful).

                Better yet, your web server is probably already keeping this information
                in it's logs. Apache and IIS both support standard "Common" format for
                web hit logs, which includes client IP address and referring URL.

                Good luck,

                --

                Bryan Field-Elliot




                Elmbrook wrote:[color=blue]
                > I'm trying to figure out how I can record the statistics of the visitors to
                > my website, where they came from etc and send this to an ASP page.
                >
                > Are there Javascripts available for recording, referreal, domain etc?
                >
                > Thanks for your help
                >[/color]

                Comment

                • Elmbrook

                  #9
                  Re: need help understanding this code.

                  Thanks, but the problem is that some of my webpages are static and are being
                  served by my local ISP. So when I found that this company had a way of
                  sending stats to their server from my static page, I was interested in how
                  they did it.



                  "Elmbrook" <elmbrook@parad ise.nospam.net. nz> wrote in message
                  news:0bJdb.4329 $tv1.542738@new s02.tsnz.net...[color=blue]
                  > I'm trying to figure out how I can record the statistics of the visitors[/color]
                  to[color=blue]
                  > my website, where they came from etc and send this to an ASP page.
                  >
                  > Are there Javascripts available for recording, referreal, domain etc?
                  >
                  > Thanks for your help
                  >
                  >
                  > "Bryan Field-Elliot" <bryan@netmeme. org> wrote in message
                  > news:IhIdb.4551 17$Oz4.260098@r wcrnsc54...[color=green]
                  > > That's some dense shit, dude. But seriously I don't think you quoted all
                  > > the relevent code to make heads or tails of this, looks like you only
                  > > quoted the last line or two.
                  > >
                  > > These two statements:
                  > >
                  > > EXw?"":EXw="na" ;
                  > > EXb?"":EXb="na" ;
                  > >
                  > > All they do is, if EXw and EXb are null, then set them to "na" (as in
                  > > Not Available?). But it must be somewhere earlier in the code where they
                  > > are setting EXw and EXb to initial values in the first place.
                  > >
                  > > In regards to the "j=y" statement; the way you've quoted the code, the
                  > > variable j (and value y) are used entirely on the server. There is no
                  > > client-side javascript here with a variable j and value of y. You need
                  > > to look on the server side script (if you have it) to find out what the
                  > > "j=y" is all about.
                  > >
                  > > Did you inherit this code from another developer, or are you trying to
                  > > *ahem* learn from some other site's techniques?
                  > >
                  > > --
                  > >
                  > > Bryan Field-Elliot
                  > > http://netmeme.org
                  > >
                  > >
                  > >
                  > > Elmbrook wrote:[color=darkred]
                  > > > Hi,
                  > > >
                  > > > I've been trying to figure out this javascript code used here (this[/color][/color][/color]
                  code[color=blue]
                  > is[color=green][color=darkred]
                  > > > used for supplying browser info to a tracking company):
                  > > >
                  > > > In particular I'm trying to understand this line:
                  > > > EXd=document;EX w?"":EXw="na";E Xb?"":EXb="na" ;
                  > > > and this one: EXd.write("<img
                  > > >[/color][/color]
                  >[/color]
                  src=\"http://t0.extreme-dm.com","/0.gif?tag=abc&j =y&srw="+EXw+"& srb="+EXb+"&[color=blue][color=green][color=darkred]
                  > > > ","l="+escape(E Xd.referrer)+"\ " height=1 width=1>");//-->
                  > > >
                  > > > Why do they have a variable j=y defined? There is no 'j' variable[/color][/color]
                  > defined[color=green][color=darkred]
                  > > > in the code.
                  > > >
                  > > > If I modify the http://t0.extreme-dm.com and send the results to my[/color][/color][/color]
                  ASP[color=blue]
                  > page[color=green][color=darkred]
                  > > > and use Querystrings to see what the values are, I only get the Screen[/color][/color]
                  > width[color=green][color=darkred]
                  > > > and colour depth values. The referrer information is not showing. I[/color][/color]
                  > also[color=green][color=darkred]
                  > > > don't understand how they can extract users country domain from this[/color][/color]
                  > code.[color=green][color=darkred]
                  > > >
                  > > > Thanks
                  > > > Tristan
                  > > > www.backpackpro.com
                  > > >
                  > > >
                  > > > ----------- Complete code below ---------------
                  > > >
                  > > >
                  > > > <a target="_top" href="http://t.extreme-dm.com/?login=abc"> <img
                  > > > src="http://u1.extreme-dm.com/i.gif" height=2
                  > > > border=0 width=2 alt=""></a>
                  > > > <script language="javas cript1.2"><!--
                  > > > EXs=screen;EXw= EXs.width;navig ator.appName!=" Netscape"?
                  > > > EXb=EXs.colorDe pth:EXb=EXs.pix elDepth;//-->
                  > > > </script>
                  > > > <script language="javas cript"><!--
                  > > > EXd=document;EX w?"":EXw="na";E Xb?"":EXb="na" ;
                  > > > EXd.write("<img src=\"http://t0.extreme-dm.com",
                  > > > "/0.gif?tag=abc&j =y&srw="+EXw+"& srb="+EXb+"&",
                  > > > "l="+escape(EXd .referrer)+"\" height=1 width=1>");//-->
                  > > > </script>
                  > > > </p>
                  > > > <noscript><im g height=1 width=1 alt=""
                  > > > src="http://t0.extreme-dm.com/0.gif?tag=abc&j =n"></noscript>
                  > > >
                  > > >[/color]
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Spamless

                    #10
                    Re: need help understanding this code.

                    In article <he2wfspk.fsf@h otpop.com>, Lasse Reichstein Nielsen wrote:[color=blue]
                    > Spamless <Spamless@Nil.n il> writes:
                    >[color=green]
                    >> This uses
                    >>
                    >> A?B:C
                    >>
                    >> If A is true, then do B, otherwise do C.[/color]
                    >[color=green]
                    >> If A is not a boolean test, but some variable,
                    >> then A? just checks if A is defined.[/color]
                    >
                    > That is not strictly correct.
                    >
                    > If A is an undeclared variable, then "A?B:C" fails with an "undeclared
                    > variable". If A is a declared variable, then its value is converted to
                    > a boolean (as by the Boolean function). The values that are converted
                    > to false are: 0, NaN, undefined, null, "" (empty string), and false
                    > itself.[/color]

                    Yes. I should have been clearer.

                    var A;

                    declares A (but it hasn't been defined to be anything)
                    and A?"":A="na"
                    will define it.

                    Without declaring it, you should just get an error.

                    (I hope the author of the page delcared A somewhere ...)[color=blue]
                    >
                    > So, if A is defined but has the value 0, the "else" branch is still
                    > used.[/color]

                    Yes, that's true too.

                    Comment

                    Working...