• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

How do I prevent a webpage that I normal load in a IFrame from being loading on its own.

I have a main page with my navigation on it.  There is a IFrame on this page that I use for loading other pages keeping my navigation and my title always in place.  I have seen example for how to do this with frames but I am not having luck getting the same code to work for an IFrame.
2 Solutions
assign name to your iframe and use javascript . as u can do in frame
I would not use IFRAME at all, as some browsers can have it's support totally disabled due to security settings while others don't support IFRAMEs at all.
Frameset is, however, supported even by older browsers - I would go this way, if you need frames on your page.
Of course you can ignore this comment, resulting in (possibly very few) people being unable to navigate throughout your page.

... and that frameset code you came across - will work for you, too :-)
TBWDEVELOPAuthor Commented:
Okay if I roll back the use to a 3 frame page.  Top, Left, Main the normal stuff.  The problem I then run into is how to get my popup menu control that is in the Left frame to break out of that frame and display across the Main frame.  And I can't not inbed code on a couple of the pages that I would load into the Main Frame to support the pop up menu.
Okay, seems you would have some design problems with those famesets.
I just don't quite understand the part about your popup menu. What sort of popup menu it is? Is it one that expands over whole page width?

Regarding that restriction, you might be able to use "parent.document.location" to check whether parent page is your main website.
As an example, "parent.document.location" will say "www.yoursite.com" if content is loaded into IFRAME or "www.yoursite.com/not_allowed_to_be_displayed_on_its_own.html" if your page is loaded on its own outside that IFRAME.

Hope this helps.

Also, try to think about design without IFRAMES or FRAMES when possible, as this is not very recommended these days.
I know that it's much easier to use frames when you create a static page and I would use frames myself in such a situation. Gladly, I do PHP websites :-)
Add this to the page that loads in the iframe...

<script type="text/javascript">
if(self.location.href == top.location.href){
location.href = "index.htm"; // or whatever page you would rather load that contains your iframe
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now