colickyboy Posted January 30, 2007 Share Posted January 30, 2007 I have a site that used iframes to call external files via the src attribute. I've since changed my code to comply with XHTML 1.0 transitional and iframes are not supported.I thought I could replace the iframe with CSS (overflow: auto) and use a PHP include...and it worked except for the major fact that it broke my menus.My original setup was:menu.php: <a href="?page=contact">Contact Us</a>main.php: $page=$_GET["page"]; if ($page=="contact") {echo '<iframe scrolling="auto" src="contact.php"></iframe>';}So when a user clicked the "Contact Us" link, they would be on the contact.php page.But when I replaced that code with a PHP include:main.php: if ($page=="contact") { echo '<div class="iframe">'; include("contact.php"); echo '</div>';}the user was actually on the index.php page. Not only did this hose my contact page, but it also caused any page in my site that referenced a relative path to be off since the URL was no longer (for example) [b]correctpage.php?id=777[/b] but instead [b]index.php/correctpage.php?id=777[/b].I realize that "include" merely substitutes code from the external file, leaving the URL the same as the calling URL...whereas the SRC attribute in the iframe tag was actually calling the external file. So my question is: Is there a way to call an external file without using an iframe?As an aside, I tried the <OBJECT> tag:echo '<object type="text/html" data="contact.php" class="iframe"></object>';...and it worked except that the page lost all style info from my external css file. I'm hoping there's a relatively painless PHP way to actually call an external file and thereby still retain reference to the css file. Link to comment https://forums.phpfreaks.com/topic/36355-how-to-use-external-file-without-using-include/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.