Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Problem in iframes ?

  1. #1
    Join Date
    Jul 2010
    Posts
    45
    Thanks
    6
    Thanked 4 Times in 2 Posts

    Question Problem in iframes ?

    hi,
    i want to open a iframe with it parent page, when click link on another parent page.
    as an example,

    parent_1.html
    Code:
    <html>
    <body>
    
    <!--logo, header & main details-->
    
    <!--iframe contain only the content-->
    <p><iframe src="parent_1-iframe.html" width="100%" scrolling="no" height="100%"></iframe></p>
    
    <!--footer & other details -->
    </body>
    </html>
    parent_1-iframe.html
    Code:
    <html>
    <body>
    
    <div >
    
    content content content content content content 
    content content content content content content
    content content content content content content 
    content content content content content content 
    content content content content content content
    
    <!--when click on "CLICK HERE"(link in the parent_2.html) 
    should come to this place with parent_1.html -->
    content content content content content content 
    
    content content content content content content 
    content content content content content content 
    
    </div>
    
    </body>
    </html>

    parent_2.html
    Code:
    <html>
    <body>
    
    <!--logo, header & main details-->
    
    <!--iframe contain only the content-->
    <p><iframe src="parent_2-iframe.html" width="100%" scrolling="no" height="100%"></iframe></p>
    
    
    <a href="?????">CLICK HERE</a>
    
    
    <!--footer & other details -->
    </body>
    </html>
    when click on "CLICK HERE" (link in the parent_2.html), it should go to middle of the parent_1-iframe.html with it's parent page (parent_1.html).
    because when just open parent_1-iframe.html, it will not contain header, logo & footer. so i could not use,

    parent_2.html
    Code:
    <a href="parent_1-iframe.html#mylink">CLICK HERE</a>
    parent_1-iframe.html
    Code:
    <a name="mylink"></a>

    I hope you understand my problem... so please someone help me....
    thanx.

    .
    Last edited by M rosi; 02-23-2011 at 06:49 AM.

  2. #2
    Join Date
    Jul 2010
    Posts
    45
    Thanks
    6
    Thanked 4 Times in 2 Posts

    Default

    is it impossible????
    please someone help me..................

  3. #3
    Join Date
    Oct 2010
    Posts
    75
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    ok im not sure which problem you mean so im going to answer both and hope that one of them are right on informing you.

    to use iframes, as far as i know most poeple create an html file for each NEW content they want brought into the frame. they can use a link to call that html file INTO the iframe.

    now, to jump down to a certain section of a page is a different story, im not sure how thatd be done within the iframe if the button is OUTSIDE of the iframe but let me know if this is what u mean and ill grab you the code. what this does is when you click a button, it scrolls down to the part of the page that you put the key word (hidden)
    so if i make the button go to key word FROGSANDBUTTONS
    and i put the word FROGSANDBUTTONS all the way 3/4s of the way down a vertically long page, it will jump down to where ever i put it.

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Googling something like 'anchor in iframe' should help
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #5
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,879
    Thanks
    49
    Thanked 265 Times in 257 Posts
    Blog Entries
    56

    Default

    Hello M rosi,
    You want a link in an iframed page to go to an anchor in another iframed page, where the iframed pages are not contained in the same main page. I googled around, no success.
    So I made a script of my own (see below). The important thing to note is that you cannot go from an iframed page (contained in a main page MP1) to an anchor in another iframed page (contained in another main page MP2) unless you have the 2 iframed pages encompassed by one and the same main page (other than MP1 and MP2). Let's call that main page 'index.html'. Also, the iframed pages should be dynamically generated. Let's call them 'parented_1.html' and parented_2.html, respectively.
    With this in mind, try the following:
    index.html:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <title></title>
    <style type="text/css">
    iframe {position: absolute; left:10%; top: 10%; width:89%; height: 89%; border:1px solid black; background: white}
    body {background: #dedede}
    </style>
    
    <script type="text/javascript">
    contentURL = parent.document.URL.substring(parent.document.URL.indexOf('?')+1, parent.document.URL.length);
    if (top.location == contentURL)top.location.href='index.html?parented_1.html';
    onload=function()
    {
    var OBJ = document.createElement("iframe");
    OBJ.setAttribute("src", contentURL);
    OBJ.setAttribute("name", contentURL);
    OBJ.setAttribute("id", "content");
    OBJ.setAttribute("frameborder", "0");
    document.body.appendChild(OBJ);
    }
    </script>
    
    </head>
    
    <body><div>
    
    <a href="index.html?parented_1.html">parented_1.html</a><br>
    <a href="index.html?parented_2.html">parented_2.html</a>
    </div></body>
    </html>
    parented_1.html:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <title></title>
    <script type="text/javascript">
    function orph(){
    if (top.location == self.location)
    top.location.href="index.html?" + document.URL
    }
    window.onload=orph;
    </script>
    </head>
    
    <body><div>
    This is parented_1.html, iframed in index.html<br>
    <br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>
    <a name="mylink"></a>WE LAND HERE COMING FROM A LINK IN parented_2.html<br>
    <br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br><br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br><br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>
    </div>
    </body>
    </html>
    parented_2.html:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <title></title>
    <script type="text/javascript">
    //This keeps the iframed pages from showing without their main page
    function orph(){
    if (top.location == self.location)
    top.location.href="index.html?" + document.URL
    }
    window.onload=orph;
    </script>
    </head>
    <body><div>
    This is parented_2.html, iframed in index.html<br>
    <a href="javascript: void(0)" onmousedown="top.location.href='index.html?parented_1.html#mylink'" >go to an anchor in parented_1.html, also contained in index.html</a>
    </div></body>
    </html>
    Arie Molendijk.
    Last edited by molendijk; 02-25-2011 at 10:40 AM. Reason: Highlighting important parts

  6. The Following User Says Thank You to molendijk For This Useful Post:

    M rosi (02-25-2011)

  7. #6
    Join Date
    Jul 2010
    Posts
    45
    Thanks
    6
    Thanked 4 Times in 2 Posts

    Default

    it s nice code. thank you for helping meee...

    but it's not the exactly solution what i want. what i really want is,

    there should be 2 different parent pages (lets say "index.html" & "other.html") for different iframes ("parented_1.html" & "parented_2.html")

    index.html ------> parented_1.html
    other.html ------> parented_2.html

    i will explain by your symbols.....

    • when we are in the "index.html", the iframe is "parented_1.html" (it's fine).
    • when we click the link parented_2.html on "index.html" it should straightly (do not want to give a another link to go to middle of the )"parented_1.html"go to middle of the "parented_2.html" (not middle of the "parented_1.html")
    • since different iframe has different parent page, "parented_2.html" should open with it's own parent page which is "other.html"


    in other word when click the link parented_2.html on "index.html" should open "other.html" with it's iframe "parented_2.html" which has scrolled to middle of the iframe.

    it's very confuse. but i hope you will not misunderstand this.

    thank you once again. hope you help me.........

  8. #7
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,879
    Thanks
    49
    Thanked 265 Times in 257 Posts
    Blog Entries
    56

    Default

    Quote Originally Posted by M rosi View Post
    in other word when click the link parented_2.html on "index.html" should open "other.html" with it's iframe "parented_2.html" which has scrolled to middle of the iframe.
    Do you mean the link that is outside the iframe (top-left of page)?
    ===
    Arie.

  9. #8
    Join Date
    Jul 2010
    Posts
    45
    Thanks
    6
    Thanked 4 Times in 2 Posts

    Default

    Yes, the link should be lie outside from the iframe.

  10. #9
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,879
    Thanks
    49
    Thanked 265 Times in 257 Posts
    Blog Entries
    56

    Default

    Hi M rosi,
    What you want is not possible, I'm afraid. As I said, you cannot go from an iframed page (contained in a main page MP1) to an anchor in another iframed page (contained in another main page MP2) unless you have the 2 iframed pages encompassed by one and the same main page (other than MP1 and MP2).
    Without the 'anchor requirement', there should be a solution, though.
    ===
    Arie.

  11. #10
    Join Date
    Jul 2010
    Posts
    45
    Thanks
    6
    Thanked 4 Times in 2 Posts

    Default

    Thank you very much molendijk.

    is it impossible!
    but still i'm trying, hoping that it can be achieve.
    can't we get some assistance from javascript ??

Bookmarks

Posting Permissions

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