www.webdeveloper.com
Results 1 to 2 of 2

Thread: Position Iframes

  1. #1
    Join Date
    Jul 2012
    Posts
    4

    Position Iframes

    Hi all,

    I am using an iframe to display pages that I load from a menu on the parent page. I don't have the ability to modify the pages I'm linked to. On one of the pages, there is navigation that I don't want my end users to have access to. My best solution to prevent access to this is to position the page below the navigation on loading, and lock the iframe's scrolling.

    However, since I load multiple pages, I need to have this positioning change depending on the link from the menu that the users select.

    I attempted to create a Javascript function to solve this problem.

    Code:
    <head>
    <script language="JavaScript">
    function repositionIframe(iframeId, iframeMarginHeight)
    {
    if (iframeMarginHeight>0)
    {
    document.getElementById(iframeId).style.marginheight=iframeMarginHeight;
    }
    }
    </script>
    </head>
    In my link, I include this:

    Code:
    onclick="repositionIframe('iframe', 200)"
    This isn't working. Does anyone know why, or an alternative solution? I am very new to JavaScript so it could be something basic like syntax.

  2. #2
    Join Date
    Mar 2011
    Posts
    1,108
    'marginwidth' and 'marginheight' feel more like 'padding' to me, and it can be tricky to manipulate them with good cross-browser results. I'd probably recommend setting those attributes to 0 and rely on the standard CSS margin property to style an <iframe>.
    Rick Trethewey
    Rainbo Design

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles