Results 1 to 4 of 4

Thread: Target a page and load target iframe

  1. #1
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Target a page and load target iframe

    i've two different section with different layout on my website.

    I've to target the other layout loading a specified page in the iframe.

    i've tried this:

    <a href="/prova/index2.htm" onClick="parent.I1.location.href = '/prova/giochi/magic.htm'" target="_top">

    but it load in the iframe the initial page and not magic.htm


    solution?

    thanks

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Why would there be one link in the href and another in the onclick event? And why one target in the target attribute and another in the onclick event?

    Anyways, if you want magic.htm in the iframe named I1, I'd do this:

    HTML Code:
    <a href="/prova/giochi/magic.htm" onclick="parent.frames['I1'].location = '/prova/giochi/magic.htm';return false;" target="I1">
    or just:

    HTML Code:
    <a href="/prova/giochi/magic.htm" target="I1">
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I think I may have misunderstood your question. If you want to change the top page and the iframe is on the new top page, you cannot load to it from the link, but you could load to it using a query processed on the new top page:

    HTML Code:
    <a href="/prova/index2.htm?I1=prova%2Fgiochi%2Fmagic.htm" target="_top">
    Then on /prova/index2.htm in the body, after the iframe named I1, have it like:

    Code:
    <iframe name="I1" src="about:blank" width="300" height="300" scrolling="auto" frameborder="1"></iframe>
    <script type="text/javascript">
    function getQval(n, m) {
    /* n=name, m=searchString(optional) */
    if(!arguments[0]||typeof n!='string')
    return null;
    var r=new RegExp('[?&;]'+n+'=([^&;#]*)'), m=arguments[1]?m:location.search;
    return (m=r.exec(m))? unescape(m[1]) : null;
    }
    if(getQval('I1'))
    window.frames['I1'].location=getQval('I1')
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks a lot it work =)

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
  •