Solved

IE8, iframes, and refreshing the browser

Posted on 2013-11-04
11
592 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Jquery GMAP3 Hierarchy 1 24
JQuery JavaScripot loop though RadioButtonList 4 25
replace link with jQuery 4 11
Button and js nou working 3 6
This article discusses four methods for overlaying images in a container on a web page
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
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
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…

776 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