Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Iframes and parent window handling....

    Here is my problem. The main layout of the site contains the navigation and the banners. Under that is a table that contains an iframe where all content is displayed. I don't want someone to be able to pull up an html page that under normal circumstances would show in the iframe without the parent. I hope I said that right. Basically I don't want pages to be viewable without my navigation and banners. Is there a way through javascript to check to see if the parent windows is there, and if not go to the main htm page and insert the page in the main iframe....

    I attempted to search the forum for an answer and could not find one. Please excuse me if someone has already covered this issue.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Please try the following placed in the page in the iframe


    <script type="text/javascript" language="javascript">
    <!--
    if(document.location == top.document.location)
    document.location = "parent.htm"
    //-->
    </script>


    Parent.htm would be the name of your parent page
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do appreciate the fast reply, but another concern was to be able to go to the parent window and also insert the page the user was trying to access without it into the iframe it was originally supposed to be inside

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Please try the following example



    In the parent page.

    <script type="text/javascript" language="javascript">
    <!--
    loc="page1.htm" // default iframe page
    var str = location.search;
    if(str != ""){
    loc=str.substring(1, str.length)
    }

    function load_frame(){
    document.getElementById('iframe_id').src=loc
    }

    // add onload="load_frame()" to the opening BODY tag

    // -->
    </script>

    <iframe id="iframe_id" src=""></iframe>

    In the page loading into the iframe

    <script type="text/javascript" language="javascript">
    <!--
    if (self == top){
    var url = self.location;
    top.location.href = "parent_page.htm?" + url;
    }
    // -->
    </script>


    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #5
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow... worked like a charm. Much appreciation. You made it look so easy. I took a totally different approach. Thanks again.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •