Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[php] Forcing page in iframe

Status
Not open for further replies.

njitter

Technical User
Sep 4, 2001
122
0
0
US
Hi,

i wonder if the following code can be converted to PHP.
I have the following html/javascript code:

::index.htm::
Code:
<html>
<head>
<title>Index</title>
</head>
<body>

<script language="javascript">
// writes in the iframe
contPage = (location.search.substring(1))? location.search.substring(1) : 'page1.htm';

contPage = unescape(contPage);

document.write('<center>');
document.write('<iframe src="'+contPage+'" name="content" height="300" width="400">');
document.write('</iframe>');
document.write('</center>');

</script>
</body>
</html>

:: page1.htm ::
Code:
<html>
<head>
<title>Page 1</title>
</head>
<body>

<script LANGUAGE = "JavaScript" src=framed.js></script>

<h1>Test page</h1>

</body>
</html>

::framed.js::
Code:
pageLoc = self.location;
pageAdd = top.location;

if (pageLoc == pageAdd) {
contentSrc = escape(pageLoc);
contPage = 'index.htm?' + contentSrc;
top.location.href = contPage;
}

This works fine except that you get a ugly URL like Is there a way to hide the URL string or to make it look like a random string?

I found this php code somewhere on the net. Is does something similair as the above:

::index.php::

Code:
<iframe src="<?php
echo ($_GET['page']?$_GET['page']:"indextext") . ".php";
?>"></iframe>

::parkhopper.php::

Code:
<script type="text/javascript">
if(top.location.href==self.location.href) {
top.location.href = "index.php?page=parkhopper";
}
</script>

The problem with the code above is that i also load pages with an URL with parameters in my iframe. These would not work..

---
It's never too late to do the Right thing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top