Forum Moderators: coopster

Message Too Old, No Replies

Force redirect page to an iframe.

         

LionKing

9:03 pm on Jun 4, 2006 (gmt 0)

10+ Year Member



Hello all,

I am trying to force the opening of am html page in an iframe created within my PHP CMS.

The idea is that when a user calls the page mysiteurl/123.html, they will be redirected to a page in my CMS such as mysiteurl/content.php?id=1 but I would also like the "mysiteurl/123.html" to be sent as a post/get parameter so that I can have it as the SRC of the iframe embedded in the mysiteurl/contetn.php?id=1 page.

Thank you. Cheers.

eelixduppy

12:38 am on Jun 5, 2006 (gmt 0)



How about this?

<script language="javascript">
window.location = "http://www.mysiteurl.com/content.php?id=1&src=123.html";
</script>

Then the page id is $_GET["id"] and the source for the frame is $_GET["src"]. I think this should work as you want. Good luck!

LionKing

1:17 am on Jun 5, 2006 (gmt 0)

10+ Year Member



Thanks for the reply.

I'm using this...
----------
<script type="text/javascript">
if (window == top) {
var url='window.location.replace("http://www.example.net/?var1='+window.location.href+'")';
eval(url);
}
</script>
----------

This gets me redirected to the correct place.

Now I am looking for a way to use the var1= as the iframe source.

The problem I am encountering right now is that I am trying to have this appear in a CMS's content manager, so it can't use $_GET and the html equivalent get(var1) puts in quotes around it all the time automatically.

Still looking.
Cheers.

[edited by: coopster at 2:29 pm (utc) on June 5, 2006]
[edit reason] generalized url TOS [webmasterworld.com] [/edit]

LionKing

1:02 pm on Jun 6, 2006 (gmt 0)

10+ Year Member



Along with the code in the previous post.

The previous post shows how to redirect a page when it is't already open in an frame.

The following will then show the previous page in an iframe.


$get_url = $_GET['var1'];
print "<iframe id=\"myframe\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\" vspace=\"0\" hspace=\"0\" style=\"overflow:visible; width:100%; display:none\" src=\"$get_url\"></iframe>";

Very useful when trying to show pages within an existing layout, or inside a CMS.

Cheers.