Solved

IFRAME resizing issues in asp.net web applications.

Posted on 2010-09-08
11
491 Views
Last Modified: 2012-05-10

I have a master page that has an IFRAME, which we use for resizing. Locally, when we are using our web application within our network, the resizing works perfectly for both Firefox and IE. However, when I access the web application from outside the network the resizing doesn't always work. Most of the time, the offsetheight for the div(container is the name) is not correct, thus I don't see all the results that I need to see in the IFRAME Here is the resizing code below.

function resizeTheFrame() {
var iframe = document.getElementById('innerFrame');
var containerHeight = document.getElementById('container').offsetHeight;
var DefaultPageHeight = 400;
if (containerHeight > DefaultPageHeight) {
var heightdiff = 100;
}
else {
var heightdiff = DefaultPageHeight - containerHeight;
}
containerHeight = containerHeight + heightdiff;
var counter = parent.top.window.location.href.lastIndexOf("/");
var urlStr = parent.top.window.location.href.substring(0, counter + 1);
iframe.src = urlStr + "resizer.htm?height=" + containerHeight;
}

Parent page and child page are in in same domain
0
Comment
Question by:theresadean
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
11 Comments
 
LVL 3

Assisted Solution

by:Marbleman
Marbleman earned 250 total points
ID: 33631308
Put some debug-alerts in the code that displays parent.top.window.location.href and see what you get there:

Maybe you do not have access to that due to some Cross-Domain security issues...
0
 

Author Comment

by:theresadean
ID: 33631492
Ocassionally, the IFRAME will work perfectly in that I would get the correct height and I would see all the data that I need to see.  Plus we are using the same domain for the parent and child.
0
 
LVL 3

Expert Comment

by:Marbleman
ID: 33631532
can you supply a link to the complete page?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:theresadean
ID: 33631759
I won't be able to because it contains sensitive data.

I should have mentioned this earlier, but there's another parent page(default.aspx page), which the master page of the web application is the child, and the web app is in the master page.  The master page and the its web application are both inside the default.aspx page.
0
 
LVL 3

Expert Comment

by:Marbleman
ID: 33632245
I am sure there is a solution but without some code to test it is impossible to figure that out. You should store the html-Source from the browser and set up a little test scenario without sensitive data
0
 

Author Comment

by:theresadean
ID: 33636777
Attached are two files:  IFRAMEERROR.bmp(where a user was attempting to use it outside our network.  The gray footer box is covering the rest of the data), and IFRAMEWORKS.bmp(where the iframe works when accessing the site within our network.  The gray footer box is not covering any of the data).  You'll notice the user and myself are not using the same exact browser versions, but this is happening on any Firefox or IE browser we use.

also the javascript code is in a js file, which gets initialized in the page_init sub in the master page

 Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Dim portalScript As New HtmlGenericControl
        Dim globalScripts As New HtmlGenericControl
        Dim configVariable As String = ""
        Dim jsSource As String = ""
        Dim otherScripts As String = ""

        configVariable = System.Configuration.ConfigurationManager.AppSettings("PortalEnvironment")

        If Not configVariable Is Nothing Then
            If Not configVariable = "local" Then
                jsSource = ResolveUrl("~/App_Javascript/KIT_Resizer.js")

                portalScript.TagName = "script"
                portalScript.Attributes.Add("type", "text/javascript")
                portalScript.Attributes.Add("language", "javascript")
                portalScript.Attributes.Add("src", jsSource)

                Me.Page.Header.Controls.Add(portalScript)
            End If
        End If

        otherScripts = ResolveUrl("~/App_Javascript/global.js")

        globalScripts.TagName = "script"
        globalScripts.Attributes.Add("type", "text/javascript")
        globalScripts.Attributes.Add("language", "javascript")
        globalScripts.Attributes.Add("src", otherScripts)

        Me.Page.Header.Controls.Add(globalScripts)
    End Sub
IFRAMEERROR.bmp
IFRAMEWORKS.bmp
0
 

Author Comment

by:theresadean
ID: 33661655
Hey Marbleman,

Have any thoughts or ideas why this is happening based on what I've sent to you?

0
 

Assisted Solution

by:theresadean
theresadean earned 0 total points
ID: 33904313
We have found a solution
0
 

Accepted Solution

by:
theresadean earned 0 total points
ID: 33904368
In the relevant pages of the web appliacation, we added this sub below:

Protected Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRenderComplete
        Page.ClientScript.RegisterStartupScript(Me.GetType, "rest", "resizeTheFrame();", True)
    End Sub

Also in the master page, we moved the IFRAME tag just below the form tag
<iframe id="innerFrame" src="javascript:false;" style="position : absolute; top : 0px; left : 0px; visibility: hidden;"></iframe>

Doing these two things helped render the IFRAME correctly when the user accesses the site outside our network.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

739 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