1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need to get location of iframe when source is not on server

Discussion in 'HTML & JavaScript' started by artizhay, Jan 18, 2011.

  1. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,867
    Likes Received:
    1,335
    I have a content locker that is using a nested iframe (GODcpa-style) to display an offer. Currently, I am using the standard gateway method of checking the length of the history and if the history lengths don't match, then drop the gateway.

    However, as various CPA companies use redirects on their offers, some of my iframed offers go through redirects of different page lengths, thus making the javascript think the offer was completed because the history length was extended. This is not good for me.

    (Just as a side question: one of the companies I'm with gives a tracking link rather than a direct offer link. The tracking links redirects to the offer. As a CPA noob, my question is would it be safe just to the actual offer link, since it still has my affiliate ID and everything so it would credit my leads? This would eliminate the iframe problem.)

    To get an understanding of what I'm doing (these are just test files), here is the source:
    Landing page:
    HTML:
    <html>
    <head>
    <script type="text/javascript">
    setInterval("checkLoc()", 2000);
    function checkLoc() {
    	// alert(document.getElementById("one").contentWindow.document.frames[1].contentWindow.location.href);
    	alert(document.getElementById("one").contentWindow.document.getElementById("location").innerHTML);
    }
    </script>
    </head>
    <body>
    <iframe src="test.php" id="one"></iframe>
    </body>
    </html>
    Inner frame (test.php):
    HTML:
    <html>
    <head>
    <script type="text/javascript">
    setInterval("updateLocation()", 100);
    function updateLocation() {
    	document.getElementById("location").innerHTML = document.getElementById("two").contentWindow.location;
    }
    </script>
    </head>
    <body>
    <iframe src="http://www.google.com/" id="two" name="name"></iframe>
    <div id="location" style="display:none;"></div>
    </body>
    </html>
    As you can see, the inner frame is updating a hidden DIV element every 100 milliseconds with the location of the iframe (the Google frame, which would be the offer frame) and the landing page is checking that element every 2 seconds (I would be using the location to do a compare to see if the first real page of the offer has been passed, not a redirect to the offer).

    The problem I am having is that apparently any time external content is displayed in an iframe, about:blank is returned by contentWindow.location or contentWindow.location.href. I have tried this with one iframe instead of a nested iframe and it still returned about:blank if I loaded Google.

    So what I need to know is if anyone knows how I can get the real location of that inner iframe. I can't use src because the source is always the same (it would return one of the redirect URLs, not the actual offer page), it's the actual location that's changing.
     
    Last edited: Jan 18, 2011
  2. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    You may be better off using a script that only changes the iframe once they hit a certain page.

    Basically you would set it to change the iframe when
    Step1 - affiliate.com/offer
    Step2 - affiliate.com/emailentered (script detects they have landed on this page, so it redirects.
    Step3 - mysite.com/lockedcontent

    This is cross domain scripting.

    What I am surprised is that you have an affiliate that does not bust out of an iframe.
     
    • Thanks Thanks x 1
    Last edited: Jan 18, 2011
  3. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,867
    Likes Received:
    1,335
    Is there a guide teaching how to do this?

    The e-mail submits don't seem to frame break. All of the zip submits frame break, I guess because they're not as useful as an e-mail.
     
  4. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    Code:
    <html >
    <head>
    <title>Cross-Site User Tracking</title>
    </head>
    <body >
    <form id="form1">
      <div>
      <!-- You should use a CPARedirector here, to hide the referrer -->
        <iframe src='http:// your action link that needs to be done to see locked content dotcom/' id='emailFrame' onload="checkURLs()"></iframe>
        
      </div>
    </form>
    </body>
    </html>
    <script language="javascript" type="text/javascript"> 
    var prevHistory = -1; 
    var firstLoad = true; 
    var url = "http://the page they must land on before you unlock content dotcom/"; 
    var fakedURL = "http://Cool beans content unlocked dotcom/"; 
    function checkURLs() { 
    if (firstLoad) { firstLoad = false; return; } 
    setTimeout("ChangeSource()", 100); } 
    function ChangeSource() { 
    prevHistory = history.length; 
    firstLoad = true; 
    document.getElementById("emailFrame").src = url; 
    setTimeout("checkHistory()", 50); } 
    function checkHistory() { 
    if (prevHistory == history.length) { 
    document.getElementById("emailFrame").src = fakedURL; 
    } else { history.go(-1); } 
    firstLoad = true; } 
    </script>
     
    • Thanks Thanks x 1
  5. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,867
    Likes Received:
    1,335
    Can you walk me through how this works? I thought I understood the general concept, but apparently I don't.

    To test it out, I set these:
    iframe src: http://www.google.com/ (this would be equivalent to the e-mail input page/slice)
    URL (must land on): http://www.google.com/search?hl=en&source=hp&biw=1366&bih=643&q=lol&aq=f&aqi=g10&aql=&oq= (the user search for "lol" or in CPA, entered e-mail)
    FakedURL: http://www.yahoo.com/ (equivalent to my locked content; I would actually be rewriting the code to just drop the content lock, not redirect to a page)

    However, even if I enter something else instead of "lol" or just click a link, it always redirects to Yahoo! no matter what.
     
  6. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    I really dont want to spend the next ten minutes setting up an example, but I will.
     
  7. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    quick test shows it redirects no matter what to the content.
     
  8. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    Well, I have wasted a while trying to get it to work, but have had no luck. Things may of changed from when I had this working. Here is the working PDF file with good info

    http://sharebee.com/02e3f75f
     
  9. scott22

    scott22 Newbie

    Joined:
    Jan 19, 2011
    Messages:
    1
    Likes Received:
    0
    just a quick qustion ive just signed up, how do i post a new thread, i just cant see it anywhere ?
     
  10. easyroms

    easyroms Newbie

    Joined:
    Nov 5, 2009
    Messages:
    15
    Likes Received:
    1
    This semi-complicated to do... here is one way of doing it, visited link detection. Just google "Spyjax Your browser history is not private!"

    If you know the url the user should've visited then this method should work perfectly. You'll need a bit of JS knowledge to implement this.
     
    • Thanks Thanks x 1