[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2006-05-17
Medium Priority
Last Modified: 2008-03-10
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.
Question by:TBWDEVELOP
LVL 20

Expert Comment

ID: 16705878
assign name to your iframe and use javascript . as u can do in frame

Expert Comment

ID: 16706566
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 :-)

Author Comment

ID: 16710209
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.

Accepted Solution

CyberGhost earned 1000 total points
ID: 16715811
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 :-)

Assisted Solution

MaxxBlade earned 1000 total points
ID: 16751067
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question