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

Why does the webpage go to a whitepage when I change the iframe code?

Discussion in 'HTML & JavaScript' started by Penelope Stardust, Jul 17, 2014.

  1. Penelope Stardust

    Penelope Stardust BANNED BANNED

    Joined:
    Jun 30, 2014
    Messages:
    147
    Likes Received:
    36
    Ive tried as couple of iframe codes now which work fine when i open them with their default url.

    But as soon as i try changing the url to a different one than the original i jsut get a blank white screen.

    Can anyone explain why?

    Code:
    <html>
    <head>
        <title>title</title>
        <meta name="keywords" content="keyword 1, keyword 2" />
        <meta name="description" content="Enter your page description" />
        <style>
        * {
            margin: 0;
            padding: 0;
        }
        body {
            margin: 0;
            padding: 0;
        }
        </style>
    </head>
    
    <body>
    <iframe src="google url (cant add links myself)"></iframe>
    </body>
    </html>
    The original here was peerfly homepage but as soon as I change it to google to test i get whitepage.

    Explanation please?
     
  2. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
    The site sends an http header that tells the browser "don't you dare put me inside a frame or I 'll put a horse-head on your bed while you sleep". Your browser complies.
     
    • Thanks Thanks x 1
  3. Penelope Stardust

    Penelope Stardust BANNED BANNED

    Joined:
    Jun 30, 2014
    Messages:
    147
    Likes Received:
    36
    So no way around that then? if it doesnt work it means the website forbids it? I noticed that i could do it with the root domain but not with the link with my affiliate link on, does that mean its forbidden or not since it worked on the homepage?
     
  4. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
    No way around it - the site can choose which pages to allow to be framed as it can send a different X-header per page.
     
    • Thanks Thanks x 1
  5. tommyhot

    tommyhot Newbie

    Joined:
    Sep 30, 2014
    Messages:
    19
    Likes Received:
    13
    Occupation:
    Black market
    Home Page:
    There's a way around it, but you need your own PHP script to act as a proxy.

    Example:

    Your html
    ======

    Code:
    <html><head>
        <title>title</title>
        <meta name="keywords" content="keyword 1, keyword 2" />
        <meta name="description" content="Enter your page description" />
        <style>
        * {
            margin: 0;
            padding: 0;
        }
        body {
            margin: 0;
            padding: 0;
        }
        </style>
    </head>
    
    
    <body>
    <iframe src="{url to your php script}"></iframe>
    </body>
    </html>
    Your PHP script
    =========

    Code:
    <?php
    $url = '//youraffillink/';
    
    $data= file_get_contents($url);
    
    // you can modify $data in the way you want, if needed
    
    echo $data;
    ?>
     
    • Thanks Thanks x 1
  6. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
    It 's not the same, as it is not the visitor that will visiting the "framed" page, but the server. This means he won't be logged it, count as unique ip etc. etc.

    Normally

    Visitor -> Page A -> Frame Page (gets cookies)

    Proxied

    Visitor -> Page A -> Server -> Page A with B's content (no cookies sent to B server)
     
  7. tommyhot

    tommyhot Newbie

    Joined:
    Sep 30, 2014
    Messages:
    19
    Likes Received:
    13
    Occupation:
    Black market
    Home Page:
    Good point, but even in the "normal" example you've provided I think (I'm not really sure and I don't have much time to create a test case now) a visitor can't access the framed page cookies and vice versa because of the cross-domain-origin restriction.

    But if that's not the case, you can still change the script a little to load the affiliate page via curl() (instead of file_get_contents) then forward a cookie retrieved via curl() to a visitor (via set_cookie) and it should work the way you want.
     
  8. coitza

    coitza Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 26, 2007
    Messages:
    2,566
    Likes Received:
    610
    Occupation:
    freelancer
    Home Page:
    do you really need to iframe a site that doesn't allow that or was it just for testing purposes. As it was explained each site can choose not to let people iframe their content, if you put a lot of work into it maybe you'll manage to do it though do you really need that or you were just wondering if your code is wrong (which is not, you just picked a bad testing site- google ) :)
     
  9. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
    Sorry, it was ambiguous the way I wrote it. I meant that the visitors's browser sends the cookies to the framed page's server when using an iframe.

    So, if you make a test page that has an iframe set to bhw, when you visit the test page bhw will get your bhw cookies. With proxy instead of iframe, bhw will not get your cookies (won't be logged in).