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 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Link to parent containing iframe containing external content?

    eeeek.

    ok, i need to create a link that opens a parent page that contains an iframe that contains external page content.

    i have googled my fingers off, and can't find just what i'm looking for...

    in my example:

    www.mysite.com/essays.html hosts only an iframe containing content from blogger. the blog has multiple entries, each one with a unique address. we'll say that the individual blogger post addresses are me.blogger.com/post1.html, me.blogger.com/post2.html, etc.

    currently, entering the address www.mysite.com/essays.html loads iframe content me.blogger.com/index.html.

    i need to create a link from www.mysite.com/music.html that will open www.mysite.com/essays.html and contains the iframe content me.blogger.com/post3.html

    is this possible???

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,478
    Thanks
    0
    Thanked 635 Times in 625 Posts
    Pass the me.blogger.com pagename in the querystring on the end of the essays.html link and update the essays.html page so that if a querystring is supplied then it loads the specified page into the iframe instead of index.html.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New Coder
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts
    whoa. i really have no idea what you just said (i should have told you all that i'm not very advanced in this type of stuff)...

  • #4
    New to the CF scene
    Join Date
    Feb 2013
    Location
    NY
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post
    First off, what your trying to do sounds overly complex, is there a reason why music.html can't have an iframe to posts3.html?

    What are you trying to accomplish by having the user go from music.html to essays.html then load the iframe from there?

    If you insist...
    An alternative to felgall solution is to have multiple iframes on essays.html. You could have an iframe for each post. For instance...

    <a name="post1"></a>
    Post 1
    [iframe for post 1]

    <a name="post3"></a>
    Post 3
    [iframe for post 3]

    So.... your link from music.html would be an anchor tag to essays.html#post3

    When the user from music.html clicks that link he'll go to essays.html and pop down to post3 iframe...

    May suite your needs...

  • #5
    New Coder
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts
    oh - i guess i didn't explain it correctly.

    there is only one iframe on essays.html

    in that iframe is a blogger page (blogger/index.html). on blogger/index.html is a table of contents, each headline linking to a page with its own blogger address. so, i'd like to be able to click a link on music.html and go to essays.html, with (for example) blogger/post3.html loaded in that one (and only) iframe on essays.html.

  • #6
    New to the CF scene
    Join Date
    Feb 2013
    Location
    NY
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post
    I've suggested adding a iFrame for each post..., this of course is not scalable... so that is why I've thought of another - better solution using HASH tags that requires very little code.

    essays.html
    Code:
    <div id="iframe"></div>
    
    <script>
        var post_page_name = location.hash; 
    
        document.getElementById('iframe').innerHTML = '<iframe src="http://blogsite.com/'+ post_page_name +'.html"></iframe>'; 
    </script>
    Let me explain the code...

    music.html will have a link to essays.html, a hash tag will contain the name of the post you wish to load. So....

    Code:
    http://mysite.com/essays.html#post1
    Once essays.html page loads, the location.hash code parses the current URL for the hash tag...

    The iframe is then inserted into the webpage and the iframe loads up the correct post based on the hash tag.

    PS.

    This method could be extended for different sites by adding more to the hash parameters.... Consider

    http://mysite.com/essays.html#blogsite=post1
    or ....
    http://mysite.com/essays.html#someotherblogsite=post1

    You'll need to a little extra parses using split there but it can be done.


  •  

    Posting Permissions

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