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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.