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 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    93
    Thanks
    12
    Thanked 1 Time in 1 Post

    Iframe part of page

    Hi,

    Is there a way to embed (iframe) a certain part of an external page, like the center of the external page for exmaple?

    Thanks!

  • #2
    Senior Coder
    Join Date
    Jan 2005
    Location
    Memphis, TN
    Posts
    1,788
    Thanks
    8
    Thanked 131 Times in 129 Posts
    if the external page is local, meaning not some other URL you can do that with jQuery as one way:

    Code:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $(function () {
    $('div.iframe').load("test.html #foot");
    });
    });
    </script>
    
    <div class="iframe" style="height:400px;width:600px;border:1px solid #000; overflow: auto;"></div>
    That will grab the local file test.html and load the div#foot into the div.iframe.

    If you are trying to grab an external URL then something like this:

    Code:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $(function () {
    $('iframe.iframe').attr("src", "http://google.com");
    });
    });
    </script>
    
    <iframe class="iframe" style="height:400px;width:600px;border:1px solid #000;"></iframe>
    Now if you're trying to load an external URL into your div or iframe but only load a particular section via class or id, there might be a way but, I honestly don't know how.
    Stop making things so hard on yourself.
    i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis

  • Users who have thanked harbingerOTV for this post:

    millsi80 (02-19-2009)


  •  

    Tags for this Thread

    Posting Permissions

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