iFrame target url received from browser url

Discussion in 'Web Design and Development' started by frikfrak, Mar 12, 2010.

  1. frikfrak macrumors regular

    Joined:
    Sep 17, 2007
    #1
    Hope my title gets the point across. I need someone to point me in the right direction. Here's what I'm trying to do:

    I've designed a web page, mysite.com, like this:

    <body>
    Some stuff at the top<br>
    <iFrame>ADDRESS_FROM_BROWSER_URL_INSERTED_HERE</iframe>
    </body>

    I want to be able to enter a URL in the browser like this:

    mysite.com/???whatever???=ADDRESS-THATS-INSERTED-AS-IFRAME-TARGET_HERE

    ...and have the iframe target address placed in appropriate place on the page.

    How do I go about doing this?
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    You can use PHP to parse the URL string and get any variables out of there,
    PHP:
    $url $_GET['url'];
    echo 
    '<iframe src="'$url'"></iframe>";
    JavaScript can do similar things, but takes more effort to pull out the argument, but you could have the URL as a hash in the URL too, page.html#http://...

    The method above on its own could be used maliciously by an attacker on your site, so you would probably want to sanitize the URL given. Maybe make a white-list of URLs that you're OK with having displayed.

    An alternative, setup a proxy on your site. Look into PHPproxy.
     
  3. frikfrak thread starter macrumors regular

    Joined:
    Sep 17, 2007
    #3
    This is exactly the sort of hint I needed to get started. Any other help is welcomed. Thanks
     

Share This Page