Jump to content

Iframe content depends on URL


mastubbs

Recommended Posts

Hi all!

 

This is my first post im (very) new to the world of php. I know a bit of HTML but i've been trying to fig out how to vary iframe content by URL. For example "http://mysite.com/page11.html?&iframe=page12.html" so that the iframe on page 11 would contain page 12. The script ive been using to get this to work is :

 

 

<script type="text/javascript">

function addLoadEvent(func) {

    var oldonload = window.onload;

    if (typeof window.onload != 'function') {

        window.onload = func;

    } else {

        window.onload = function() {

            if (oldonload) {

                oldonload();

            }

            func();

        }

    }

}

 

/* Credit: Original code from http://www.netlobo.com */

 

function gup( name ) {

  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

  var regexS = "[\\?&]"+name+"=([^&#]*)";

  var regex = new RegExp( regexS );

  var results = regex.exec( window.location.href );

  if( results == null )

      return "";

  else

      return results[1];

}

 

 

addLoadEvent(function() {

      var targetURL = gup("iframe");

      document.all.myIframe.src=targetURL;

})

</script>

 

 

 

Problem is this script only seems to work in IE not FF. From what little i know about PHP it seems like this would be easy to do but i have no idea how. I read that you can make a php page containing

 

<iframe src="<?php echo $_GET["iframe"]; ?> name="iframe" id="iframe" width="100%" height="320" scrolling="no" frameborder="0">fail</iframe>

 

 

I tried this and put in the url : http://mydomain.com/page11.php?iframe=page12.php but didnt work :(

 

can anyone help? Thanks in advance.

 

Matt

Link to comment
https://forums.phpfreaks.com/topic/132007-iframe-content-depends-on-url/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.