Solved

display complete web page in iframe with scroll bars

Posted on 2011-02-25
9
647 Views
Last Modified: 2012-05-11
Hi,

on one page have two iframes that displays two different web pages. Iframes hight is 900 px and width is set to 100%, scrolling is auto. Problem is that web pages are larger than size of iframe and they are not loading correctly. I want to have full size web page in iframe with scroll bars (horisontal and vertical if necessary, how to do that?
0
Comment
Question by:kahvedzic
  • 6
  • 3
9 Comments
 
LVL 10

Expert Comment

by:Asim Nazir
ID: 34978539
This Javascript function works in FF and IE:

// Sets iframe src
        function changeIframeSrc(id, url) {
            var el = document.getElementById(id);
            el.src = url;
}

Following code is used to resize iframe and called at iframe's onresize="reSize();":

/* Resizes iframe height to 100%.
        iFrame was not filling whole available area.
        So had to introduce this logic.*/
        function reSize() {
            try {
                var ifrm = document.getElementById('feedDetail');

                ifrm.style.height = '100%';
            }
            catch (e) {
                //window.status = 'Error: ' + e.number + '; ' + e.description;
            }
        }
0
 
LVL 1

Author Comment

by:kahvedzic
ID: 34978597
I did not notice any change maybe I did something wrong, this is my code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Main2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script language="javascript" type="text/javascript">
        // Sets iframe src
        function changeIframeSrc(id, url) {
            var el = document.getElementById(id);
            el.src = url;
        /* Resizes iframe height to 100%.
        iFrame was not filling whole available area.
        So had to introduce this logic.*/
        function reSize() {
            try {
                var ifrm = document.getElementById('I21');

                ifrm.style.height = '100%';
            }
            catch (e) {
                //window.status = 'Error: ' + e.number + '; ' + e.description;
            }
        }
    </script>
    <style type="text/css">
        div.hideSkiplink
{
    background-color:#3a4f63;
    width:100%;
}

div.menu
{
    padding: 4px 0px 4px 8px;
}

div.menu ul
{
    list-style: none;
    margin: 0px;
    padding: 0px;
    width: auto;
}

div.menu ul li a, div.menu ul li a:visited
{
    background-color: #465c71;
    border: 1px #4e667d solid;
    color: #dde4ec;
    display: block;
    line-height: 1.35em;
    padding: 4px 20px;
    text-decoration: none;
    white-space: nowrap;
}

div.menu ul li a:hover
{
    background-color: #bfcbd6;
    color: #465c71;
    text-decoration: none;
}

div.menu ul li a:active
{
    background-color: #465c71;
    color: #cfdbe6;
    text-decoration: none;
}
        .style1
        {
            width: 100%;
        }
        .iframe
        {
            overflow: hidden;
        }
        .menu
        {
            font-family: Verdana;
        }
        </style>
</head>
<body >
    <form id="form1" runat="server">
        <table class="style1">
            <tr>
                <td class="clear hideSkiplink">                
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
                    <Items>
                        <asp:MenuItem Text="1" Value="1"/>
                        <asp:MenuItem Text="2" Value="2">
                        <asp:MenuItem Text="3" Value="3">
                    </asp:MenuItem>
                    </Items>
                </asp:Menu>
                </td>
            </tr>
        </table>
        <table align="center" class="style1">
            <tr>
                <td style="text-align: center">
                <iframe src="http://link1.asp" runat="server" 
                        onresize="reSize();" width="100%" 
                        height="900" id="I21" 
                        name="I21" marginheight="0" marginwidth="0" scrolling="auto" >
                       <p>Your browser does not support iframes.</p>
                </iframe>
                </td>
                <td style="text-align: center">
                    <iframe src="http://link2.aspx" runat="server" width="100%" 
                        height="900" id="I22" 
                        name="I22" marginheight="0" marginwidth="0" scrolling="auto" 
                        style="overflow: visible" >
  <p>Your browser does not support iframes.</p>
</iframe></td>
            </tr>
            <tr>
                <td style="text-align: center">
    <asp:ImageButton ID="popup6" runat="server" Text="Button" ImageUrl="~/link-48x48.png" />
                </td>
                <td style="text-align: center">
    <asp:ImageButton ID="popup7" runat="server" Text="Button" ImageUrl="~/link-48x48.png" />
                </td>
            </tr>
        </table>
    </form>
    </body>
</html>

Open in new window

0
 
LVL 10

Expert Comment

by:Asim Nazir
ID: 34978658
changeIframeSrc closing } is missing :)
0
 
LVL 10

Expert Comment

by:Asim Nazir
ID: 34978669
You can also see 100% height problem solution over here http://www.amirharel.com/2009/07/28/implementing-iframe-toolbar/
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 1

Author Comment

by:kahvedzic
ID: 34978739
I add missing } but now its working even worst than it was, iframe is smaller and everything is messy, and I cant see anything normal.
0
 
LVL 1

Author Comment

by:kahvedzic
ID: 34994847
Basically problem is that I cant see full size page in iframe. I have frame with this properties width="100%" height="900" but cant see complete page with scroll bar.
0
 
LVL 1

Author Comment

by:kahvedzic
ID: 35015756
Is there any solution, suggestion, something this is really urgent to me? Thanks
0
 
LVL 1

Accepted Solution

by:
kahvedzic earned 0 total points
ID: 35084316
Solution was to put iframe in div and then with div properties define size of an iframe and with iframe properties define page visibility properties (owerflow must be se to scroll). Anyway thanks for effort and help.

Cheers.
0
 
LVL 1

Author Closing Comment

by:kahvedzic
ID: 35126331
no expert provided me quality solution so I try by myself and there it is.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now