Search code examples
javascriptjqueryhtmliframequirks-mode

Changing src of iframe in IE5 quirks mode cause full page change


I have content that is loaded into a standard frame. I have no control over the parent frame which is forcing the browser into IE5 Quirks mode. Now within my own content I am attempting to change the src of an iframe. I am using the following code:

function loadIframe(iframeName, url) {
  var $iframe = $('#' + iframeName);
  if ( $iframe.length ) {
    $iframe.attr('src',url);   
    return false;
  }
  return true;
}
loadIframe('frameID', '../myhtmlpage.html');

The issue is that when I attempt to load the new src into the iframe, the entire window reloads. I am pretty sure that this is related to IE5Quirks mode because if I pull up IE Developer tools and change to Standards mode, the iframe loads as expected. How can I get the iframe to load without issues?


Solution

  • From your comment:

    I don't have any control over the page that is being rendered in quirks mode; however, my content must be loaded into a standard frame on that page.

    I'm afraid to tell you that you are out of luck.

    IE does not support mixed rendering modes between frames on the same page. If the main page is in quirks mode, then all frames or iframes within that page will also be in quirks mode, even if they are written to be standards compliant.

    This just how it works, and you cannot override it.

    Your options, as I see them:

    1. Find a way to upgrade the parent page so that it no longer needs Quirks mode. (I appreciate that this option may not be open to you, but frankly it's shocking that anyone is still using quirks mode in 2015; the managers who think they're saving money by not upgrading whatever obsolete system this is need to be given a wake-up call)

    2. Downgrade your page so it can work in quirks mode. Note that if you're using any modern browser features, then this option may not be possible as Quirks mode will disable those features in the name of being compatible with IE5.

    3. Open your content in a pop-up window instead of a frame. This seems like it's probably the most pragmatic option. It's almost certainly going to be the least amount of work (be an order or magnitude). It may not look as good as if it's in an iframe, but at least it'll work.