Can an autosurf frame be detected?

Discussion in 'JavaScript' started by johndoes, Feb 24, 2008.

  1. #1
    Hi there,

    I want to know if a document's top window's URL can be detected through javascript. I mean can an ad network's banner javascript include like

    <script language="javascript" src="...

    detect if the page was loaded inside an autosurf frame?

    I know that you can't read top.location.href unless both top and self are from the same domain.

    However, google analytics can read it. I'm using an autosurf site now (I know it's a bad idea) to generate infilated hits. I just wonder how can their (google's) script detect that my site was loaded inside another domain's frame?

    I know it's not a moral thing but I want to learn what can and can't be done.

    Any help greatly appreciated

    Best regards,
     
    johndoes, Feb 24, 2008 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    You could attempt to read top and catch the exception:
    var inForeignFrameset=false;
    try
    {
     if(top.location.href==location.href)
     ;
    }catch(e){inForeignFrameset=true;}
    
    Code (markup):
     
    Logic Ali, Feb 24, 2008 IP
  3. johndoes

    johndoes Peon

    Messages:
    738
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I see. Thanks for your help.

    But that way you can only find out that the topmost frame is from another domain. You can't get the actual URL.

    Google analytics somehow logs my autosurf site's domain as a referer. I can't understand how that code can get the URL of the top frame.

    Any different ideas?
     
    johndoes, Feb 24, 2008 IP
  4. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #4
    It probably gets that via document.referrer
     
    Logic Ali, Feb 24, 2008 IP
  5. GonzoInDaHouz

    GonzoInDaHouz Peon

    Messages:
    265
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I was about to say the same thing.
     
    GonzoInDaHouz, Feb 24, 2008 IP
  6. johndoes

    johndoes Peon

    Messages:
    738
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    well, thanks a lot for your concern but unfortunately document.referrer simply gets the referer and I'm already cloaking the referer with nested frames etc.

    I checked again after your reply, but document.referrer returns what I expect it to return - not the autosurf domain.

    so does google have a special javascript function that somehow reads the
    "top"s URL? Aren't those guys using the same language and are limited to the same boundaries as we are?

    Any ideas?
     
    johndoes, Feb 25, 2008 IP
  7. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #7
    You need to read the referrer of the highest accessible level.
    You could try something like this (untested):
    var parentRef=self, referrer=document.referrer;
    try
    {
     while(parentRef=parentRef.parent)
      referrer=parentRef.document.referrer;
    }catch(e){}
    
    
    
    Code (markup):
     
    Logic Ali, Feb 25, 2008 IP
  8. johndoes

    johndoes Peon

    Messages:
    738
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #8
    well, thanks a lot. You're right. Altough you can't get "top"s location, you can get the nested frame's referrer, which in my case corresponds to the same URL.

    parent.document.referrer

    this gives the foreign domain.

    thanks again...

    best regards


     
    johndoes, Feb 25, 2008 IP