Solved

IE8, iframes, and refreshing the browser

Posted on 2013-11-04
11
583 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
  • 6
  • 5
11 Comments
 
LVL 58

Expert Comment

by:Gary
Comment Utility
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
Comment Utility
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
Comment Utility
<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
 

Author Comment

by:AxISQS
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:AxISQS
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
http://ecm/data/report.html/func=UpdateRecord

What is ecm - is this your localhost?
0
 

Author Comment

by:AxISQS
Comment Utility
ecm is my localhost, yes.
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

771 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

12 Experts available now in Live!

Get 1:1 Help Now