3 Replies - 668 Views - Last Post: 08 February 2014 - 04:57 AM

#1 Wolverine89  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 68
  • Joined: 14-January 14

IFrame and URL

Posted 08 February 2014 - 03:27 AM

Hi guys,

The following is my problem. I use a IFrame to load content when clicked on a button in my navigationbar. For example, when i click on the About button, the content of the about page shows up in my IFrame. This is working fine.

My question is, when i do, is there a possibility to change browsers URL aswell instead of

http://localhost/wor...bshop/Index.php

I want

http://localhost/wor...pages/About.php

<nav>
  <ul>
    <li>
        <a href="Index.php">Home</a>
    </li>
    <li>
        <a href="#">Products</a>
    </li>    
    <li>
        <a href="Pages/About.php" target="iframe">About</a>
    </li>
    <li>
        <a href="#">Contact</a>
    </li>
    <li>
        <a href="#">Shopping Cart</a>
    </li>
  </ul>
</nav>



thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: IFrame and URL

#2 Ntwiles  Icon User is offline

  • D.I.C Addict

Reputation: 148
  • View blog
  • Posts: 830
  • Joined: 26-May 10

Re: IFrame and URL

Posted 08 February 2014 - 03:42 AM

Not as such. You can do a couple different things to solve this though.

Option 1 - Hash indentifiers
Example: index.php, index.php#about

These are usually used as fragment identifiers You would be using them as page links. You'll need Javascript to grab the hash identifier and display the proper information based on the url.

Option 2 - GET data
Example: index.php, index.php?page=about

With this option you'll use PHP to grab the GET data and display the proper page.

Option 3 - Don't use iframes
Example: index.php, about.php

Do you really need to be using them for what you're trying to achieve? Are you using an iframe to just achieve a simple header/navigation bar? There are ways to do this which will give you much less pain down the road.

This post has been edited by Ntwiles: 08 February 2014 - 03:55 AM

Was This Post Helpful? 0
  • +
  • -

#3 Wolverine89  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 68
  • Joined: 14-January 14

Re: IFrame and URL

Posted 08 February 2014 - 04:35 AM

Yes i am using iframe when clicked on a button in my navbar the content of that page appears in my IFrame so when clicked on about, the content of about is in my IFrame
what is a better way? now i use php includes because they want it modular

<html> 
 
<head> 
 <link href="Css/site.css" rel="stylesheet" type="text/css" />
 </head>
 
<body> 
<div id="container">	
    	<?php include("Includes/Header.php");?>
    	<?php include("Includes/Navigation.php");?>
    	<iframe id="iframe" seamless></iframe>
    	<?php include("Includes/Footer.php");?>
</div>

</body>
</html>


Was This Post Helpful? 0
  • +
  • -

#4 Ntwiles  Icon User is offline

  • D.I.C Addict

Reputation: 148
  • View blog
  • Posts: 830
  • Joined: 26-May 10

Re: IFrame and URL

Posted 08 February 2014 - 04:57 AM

A better solution is to remove the iframe altogether, and create each page separately, using the template you just posted. You're already using includes, which will help if you have to make any changes to the template. Therefore your about.php page would be something like this (hopefully with more content):

<html> 
<head> 
<link href="Css/site.css" rel="stylesheet" type="text/css" />
</head>
<body> 
<div id="container">	
    	<?php include("Includes/Header.php");?>
    	<?php include("Includes/Navigation.php");?>
    	This is the About page!
    	<?php include("Includes/Footer.php");?>
</div>
</body>
</html>


You would save this file as 'About.php', and adjust Navigation.php to link to it.

This post has been edited by Ntwiles: 08 February 2014 - 04:58 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1