1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Buying PHP Coder. Redirection to Iframe, Iframe full page $10

Discussion in 'Programming' started by netsearch, Mar 21, 2012.

  1. #1
    Okay it seems simple enough to me, First person to solve this gets paid, first come first serve type of thing.

    <?php
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    
    if(preg_match('/microsoft|window/i', $user_agent)) {
    	$site= "http://www.yahoo.com";
    } elseif(preg_match('/mac|os x/i', $user_agent)) {
    	$site="http://www.google.com";
    } else {
    	$site= "http://www.bing.com";
    }
    
    ?>
    
    <iframe src="<?php echo $site; ?>" </frame>
    Code (markup):
    this does exactly what I want but the iframe is just a small square, I want it to be a full page, regular whole page iframe.
     
    netsearch, Mar 21, 2012 IP
  2. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    $user_agent = $_SERVER['HTTP_USER_AGENT'];

    if(preg_match('/microsoft|window/i', $user_agent)) {
    $site= "http://www.yahoo.com";
    } elseif(preg_match('/mac|os x/i', $user_agent)) {
    $site="http://www.google.com";
    } else {
    $site= "http://www.bing.com";
    }

    ?>

    <iframe src="<?php echo $site; ?>" width="100%" height="100%" frameborder="0"> </frame>
     
    creativeGenius, Mar 21, 2012 IP
  3. netsearch

    netsearch Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    I tried that and it doesnt work.
     
    netsearch, Mar 21, 2012 IP
  4. Dangy

    Dangy Well-Known Member

    Messages:
    841
    Likes Received:
    25
    Best Answers:
    2
    Trophy Points:
    155
    As Seller:
    100% - 1
    As Buyer:
    100% - 0
    #4
    
    <?php
    
     $useragent = $_SERVER['HTTP_USER_AGENT'];
    if (preg_match('|MSIE ([0-9].[0-9]{1,2})|',$useragent,$matched)) {
     $browser_version=$matched[1];
     $browser = 'IE';
     } elseif (preg_match('|Opera/([0-9].[0-9]{1,2})|',$useragent,$matched)) {
     $browser_version=$matched[1];
     $browser = 'Opera';
     } elseif(preg_match('|Firefox/([0-9\.]+)|',$useragent,$matched)) {
     $browser_version=$matched[1];
     $browser = 'Firefox';
     } elseif(preg_match('|Safari/([0-9\.]+)|',$useragent,$matched)) {
    
     $browser_version=$matched[1];
     $browser = 'Safari';
     } else {
     // browser not recognized!
     $browser_version = 0;
     $browser= 'other';
     }
     //os
     if (strstr($useragent,'Win')) {
     $os='Win';
    	$site = "http://www.yahoo.com";
     } else if (strstr($useragent,'Mac')) {
     $os='Mac';
    	$site = "http://google.com/"
     } else if (strstr($useragent,'Linux')) {
     $os='Linux';
     } else if (strstr($useragent,'Unix')) {
     $os='Unix';
     } else {
     $os='Other';
     }
     ?>
    <script language="JavaScript">
    <!--
    function resize_iframe()
    {
    
    	var height=window.innerWidth;//Firefox
    	if (document.body.clientHeight)
    	{
    		height=document.body.clientHeight;//IE
    	}
    	//resize the iframe according to the size of the
    	//window (all these should be on the same line)
    	document.getElementById("glu").style.height=parseInt(height-
    	document.getElementById("glu").offsetTop-8)+"px";
    }
    
    // this will resize the iframe every
    // time you change the size of the window.
    window.onresize=resize_iframe; 
    
    //Instead of using this you can use: 
    //	<BODY onresize="resize_iframe()">
    
    
    //-->
    </script>
    <iframe id="glu" width="100%" onload="resize_iframe()" src="<?php echo $site; ?>" </frame>
    
    Code (markup):
     
    Last edited: Mar 21, 2012
    Dangy, Mar 21, 2012 IP
  5. nhc1987

    nhc1987 Notable Member

    Messages:
    2,674
    Likes Received:
    240
    Best Answers:
    0
    Trophy Points:
    280
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    Hello,

    Please try this
    <?php
    $user_agent = $_SERVER['HTTP_USER_AGENT'];

    if(preg_match('/microsoft|window/i', $user_agent)) {
    $site= "http://www.yahoo.com";
    } elseif(preg_match('/mac|os x/i', $user_agent)) {
    $site="http://www.google.com";
    } else {
    $site= "http://www.bing.com";
    }
    ?>

    <iframe src="<?php echo $site; ?>" width="100%" height="100%" frameborder="0" scrolling="auto" style="position: absolute;top: 0;left: 0"> </frame>
     
    nhc1987, Mar 21, 2012 IP
  6. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    i think, my post was right with one correction the closing iframe tag :)

    try different sites for your testing, seems like yahoo or google does not allow themselves to be iframed.
     
    creativeGenius, Mar 21, 2012 IP
  7. netsearch

    netsearch Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    yeah i have tried with diffent sites, my or else is bing which can be iframed, I tried a lot of different variations, but I am still a noob at this so I might be overlooking something.
     
    netsearch, Mar 21, 2012 IP
  8. nhc1987

    nhc1987 Notable Member

    Messages:
    2,674
    Likes Received:
    240
    Best Answers:
    0
    Trophy Points:
    280
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #8
    Just firgured it out. The reason is that Google/Yahoo/Bing is sending an "X-Frame-Options: SAMEORIGIN" response header. This option prevents the browser from displaying iFrames that are not hosted on the same domain as the parent page.

    That means you cannot put them in an iframe. If you try with another sites, such as microsoft.com, it works fine

    Source: https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header
     
    nhc1987, Mar 21, 2012 IP
  9. netsearch

    netsearch Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #9
    none worked so far.

    @nhc1987 the sites not the problem, I changed them all to other sites when I am testing and still doesnt work.
     
    netsearch, Mar 21, 2012 IP
  10. nhc1987

    nhc1987 Notable Member

    Messages:
    2,674
    Likes Received:
    240
    Best Answers:
    0
    Trophy Points:
    280
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #10
    Are you serious? It should work if you change link to microsoft.com. As described above, except the site is intended not allowed to be framed, everything else should work.

    Try the code below. I changed all the links to microsoft.com website.

    <?php
    $user_agent = $_SERVER['HTTP_USER_AGENT'];

    if(preg_match('/microsoft|window/i', $user_agent)) {
    $site= "http://www.microsoft.com";
    } elseif(preg_match('/mac|os x/i', $user_agent)) {
    $site="http://www.microsoft.com";
    } else {
    $site= "http://www.microsoft.com";
    }
    ?>

    <iframe src="<?php echo $site; ?>" width="100%" height="100%" frameborder="0" scrolling="auto" style="position: absolute;top: 0;left: 0"> Your browser doesn't support iFrames</iframe>

    Edit: proof

    [​IMG]

     
    Last edited: Mar 21, 2012
    nhc1987, Mar 21, 2012 IP
  11. Dangy

    Dangy Well-Known Member

    Messages:
    841
    Likes Received:
    25
    Best Answers:
    2
    Trophy Points:
    155
    As Seller:
    100% - 1
    As Buyer:
    100% - 0
    #11
    My method works 100% check it here: http://clickadx.com/testing.php

    
    <?php
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    
    if(preg_match('/microsoft|window/i', $user_agent)) {
    	$site= "http://www.microsoft.com/";
    } elseif(preg_match('/mac|os x/i', $user_agent)) {
    	$site="http://www.google.com";
    } else {
    	$site= "http://www.bing.com";
    }
    
    ?>
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Iframe with 100% height - atguy.com</TITLE>
    <META NAME="Author" CONTENT="Guy Malachi">
    <META NAME="Keywords" CONTENT="100% iframe resize javascript one hundred percent ">
    <META NAME="Description" CONTENT="">
    <script language="JavaScript">
    <!--
    
    function resize_iframe()
    {
    
    
    	var height=window.innerWidth;//Firefox
    	if (document.body.clientHeight)
    	{
    		height=document.body.clientHeight;//IE
    	}
    
    	document.getElementById("glu").style.height=parseInt(height-document.getElementById("glu").offsetTop-8)+"px";//resize the iframe according to the size of the window
    	//document.getElementById("glu").height=document.body.offsetHeight-document.getElementById("glu").offsetTop-26;
    }
    
    /*
    	//Here is another way to define the function (this function reloads the page whenever the user resizes the page)
    	window.onresize=
    	function (e) 
    	{
    		location.reload();
    	};
    */
    
    window.onresize=resize_iframe; //instead of using this you can use: <BODY onresize="resize_iframe()">
    //-->
    </script>
    </HEAD>
    
    <BODY style="margin:0;padding:0;float:left;width:100%;">
    
    <iframe id='glu' width='100%' onload='resize_iframe()' frameborder="0" scrolling="auto" src="<?=$site;?>"></iframe>
    
    </BODY>
    </HTML>
    
    Code (markup):
     
    Last edited: Mar 21, 2012
    Dangy, Mar 21, 2012 IP
  12. netsearch

    netsearch Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #12
    @Dangy Pming right now
     
    netsearch, Mar 21, 2012 IP
  13. kishore415

    kishore415 Well-Known Member

    Messages:
    1,462
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    160
    As Seller:
    100% - 0
    As Buyer:
    25.0% - 1
    #13
    I checked this and it works in FF...

     
    kishore415, Mar 22, 2012 IP