Solved

IE8, iframes, and refreshing the browser

Posted on 2013-11-04
11
588 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
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
 

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

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

Suggested Solutions

Title # Comments Views Activity
html5 auto send email 7 22
html input type 3 22
javascript date picker in php while loop 5 27
compact pure CSS Read More Toggle 4 22
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn how to count occurrences of each item in an array.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

920 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

11 Experts available now in Live!

Get 1:1 Help Now