[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 496
  • Last Modified:

IFRAME resizing issues in asp.net web applications.


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
theresadean
Asked:
theresadean
  • 6
  • 3
3 Solutions
 
MarblemanCommented:
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
 
theresadeanAuthor Commented:
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
 
MarblemanCommented:
can you supply a link to the complete page?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
theresadeanAuthor Commented:
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
 
MarblemanCommented:
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
 
theresadeanAuthor Commented:
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
 
theresadeanAuthor Commented:
Hey Marbleman,

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

0
 
theresadeanAuthor Commented:
We have found a solution
0
 
theresadeanAuthor Commented:
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now