Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

IE8, iframes, and refreshing the browser

Posted on 2013-11-04
11
Medium Priority
?
620 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
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 

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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The viewer will learn how to dynamically set the form action using jQuery.
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.

610 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