Help - Search - Members - Calendar
Full Version: iFrame Troubles
Forums > Resource Center > Webmasters' Corner
Victoria322821
I always have trouble with iFrames and right now my website is currently on hiatus as I'm making a new layout for it. But whenever I make my website with iFrames; normally i just use iFrames for the sidebar never for the content, they always go haywire and I don't know how to fix it.

Whenever I would click on a link to go to a page on my website it would open in a new tab/window never on the same page and I'm not sure what's wrong with that. That's what has happened most recently. Can somone help me? I've asked help time and time again but everyone seems to be confused on what's going on so please help me.

This is my website: http://xshortytorix.webs.com

& you can access it by going to http://xshortytorix.webs.com/home.htm

or if you want to sign on it and help me out there let me know and I'll PM you my sign in info. I really hope that someone can help me!!!

Thanks, Tori.
_unsure.gif
Mikeplyts
In your sidebar.htm file, try removing the target attribute.

The target attribute only supports the following values:
  • _self
  • _blank
  • _parent
  • _top
  • frame name
The _self value tells the link to navigate to the URL specified in the same page (i.e. - no tabs or no new windows) and this is usually the default value. You may already know what the _blank value does, but that opens a new tab or new window (depending on the browser). The other three aren't really that common, so I won't go into depth on that. But, you can check out more information here.

What you're doing is specifying a name for a different frame. However, if that frame is on another page, it won't load the content in the same document. If there is no frame at all, then there's really no point. Plus, all you're doing is linking to a different page so a frame wouldn't really be important if you're only using one for your sidebar. Also, you don't need to include a full document if you're just linking the frame to a sidebar (i.e. - you don't need all the header and footer tags, just DIV and anchor tags and the sort).

However, I suggest you use a PHP include if it's for something so simple. To do that, though, you need to edit your pages to have a .PHP extension as opposed to your .HTM (HTML) extension. Then, you have to create a PHP file to store the things in your sidebar and after that, just add this code wherever you want to show your sidebar.

CODE
<?php
$path = realpath($_SERVER['DOCUMENT_ROOT']); // Gets the root (index) path for a clean include, so to speak.
include ($path . '/sidebar.php'); // This gets what is inside your PHP sidebar file. Keep in mind that you may have to edit the rest of the path depending on where your PHP sidebar file is at.
?>

This may seem like a little extra effort, but it's good for a tiny bit of experience or to get you interested in learning a new syntax. Additionally, .HTM extensions are sort of out-of-date. wink.gif

Feel free to ask any more questions you may have. Otherwise, good luck. thumbsup.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.