Solved

IE8, iframes, and refreshing the browser

Posted on 2013-11-04
11
599 Views
Last Modified: 2013-11-08
Hi everyone, I'm facing a problem in IE8 only.  The problem does not exist in Chrome, FF, or IE9+.  

What I'm doing is updating a record with a particular url then refreshing the page.  The record updates in IE8 but the page doesn't refresh.  In other browsers the page refreshes as expected.  Can you help?

In the header of my page:
<script>
window.onload = function() {
  document.getElementById("iframe_a").onload = function() {
    top.location.reload();
  }
}
</script>

Open in new window


Here is the link which you click to update the record, the refresh should occur once updated:

<script>
     var s = "http://ecm/data/report.html/func=UpdateRecord";

    document.write("<a href='"+s+"' target='iframe_a'>Auto-Assign</a>");
</script>

Open in new window


The purpose of this iframe is to update the record, but the refresh should occur on the entire page (parent):

<iframe id="iframe_a" name="iframe_a" height="0" width="0"></iframe>

Open in new window

0
Comment
Question by:AxISQS
[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
  • 5
11 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39623092
Your question makes no sense, that would continually keep loading the page.
So I don't know how you think it works in IE9,...
0
 

Author Comment

by:AxISQS
ID: 39624428
Hi GaryC123, it could be that I'm not explaining things properly or that my application is not normal.  The report that we run to update the record needs to execute in the iframe, then refresh the browser.  It works perfectly in all other browsers but my client requires IE8.  Let me know what information you need to assist.  Thanks for your time.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39624452
<script>
window.onload = function() {
    iframe = document.getElementById('iframe_a');
    var myiframe= iframe.contentDocument || iframe.contentWindow.document;
    if (myiframe.readyState == 'complete') {
        top.location.reload();
    }
}
</script>

But as I said that will just continually reload the page ad infinitum
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

Author Comment

by:AxISQS
ID: 39624825
Thanks for that, you're right - it kept reloading the page.

My original code does work, with no errors in fact.  It comes down to IE8 and what I think is an iframe issue.

When the link is clicked a report runs in the iframe.  After that runs how can we refresh the page outside the iframe?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39624937
Getting confused here.
Click a link?
The js code you posted in your opening question would cause an infinite loop, you wouldn't get to click a link. So why are you trying to run it on page load?
0
 

Author Comment

by:AxISQS
ID: 39625547
Yes, click a link as seen here:
<script>
     var s = "http://ecm/data/report.html/func=UpdateRecord";

    document.write("<a href='"+s+"' target='iframe_a'>Auto-Assign</a>");
</script>

Open in new window


When this link is clicked it updates a record using the iframe.  After the record is updated we need to refresh the parent page (to display the updated record).

Currently, the record DOES update in IE8 but the refresh does not occur.
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39625569
So forget the window.onload.

<script>
var s = "http://ecm/data/report.html/func=UpdateRecord";
document.write("<a href='"+s+"' target='iframe_a' onclick='checkload()'>Auto-Assign</a>");


function checkload() {
    iframe = document.getElementById('iframe_a');
    var myiframe= iframe.contentDocument || iframe.contentWindow.document;
    if (myiframe.readyState == 'complete') {
        top.location.reload();
    }
}
</script>
0
 

Author Comment

by:AxISQS
ID: 39625858
Gary, thanks!  Your code refreshed the page in IE8 but the UpdateRecord did not function as expected.  We built in an alert and some logic to allow for the record to update then refresh.  The only thing is, this isn't working in Chrome.  The requirements are for IE8 but I thought I'd drop this here for your feedback.

JS:
<script>
  function checkload(s) {
    iframe = document.getElementById('iframe_a');
    var myiframe= iframe.contentDocument || iframe.contentWindow.document;
    myiframe.location=s;

    alert('Your locator assignment request is being processed');
    if (myiframe.readyState == 'loading' || myiframe.readyState == 'complete' || myiframe.readyState == 'interactive') {
        top.location.reload();
    } 
  }
</script>

Open in new window


Link:
<script>
     var s = "http://ecm/data/report.html/func=UpdateRecord";

  document.write("<a href='"+s+"' target='iframe_a' onclick='checkload(s)'>Auto-Assign</a>");

</script>

Open in new window


iFrame:
<iframe id="iframe_a" name="iframe_a" height="0" width="0"></iframe>

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
ID: 39625928
http://ecm/data/report.html/func=UpdateRecord

What is ecm - is this your localhost?
0
 

Author Comment

by:AxISQS
ID: 39625951
ecm is my localhost, yes.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39625958
Why have you added in loading and interactive? The reload should only fire on complete.

When I test everything seems to be working fine.
0

Featured Post

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

738 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