iFrame target url received from browser url

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

  1. frikfrak macrumors regular

    Sep 17, 2007
    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:

    Some stuff at the top<br>

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


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

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


    Aug 16, 2005
    You can use PHP to parse the URL string and get any variables out of there,
    $url $_GET['url'];
    '<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

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

Share This Page