Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in Internet Explorer 9 (not earlier versions or other browsers) when including jQuery in an iframe

Basically I have a page that launched a fancybox iframe. In that iframe I also include jQuery. But when I testing it in Internet Explorer 9 it gives me the error

Line: 68\n Error: 'Object' is undefined`

This error is in file jquery-1.4.1.js and the line in question is the second line of this:

// Save a reference to some core methods
toString = Object.prototype.toString,
hasOwnProperty = Object.prototype.hasOwnProperty,
push = Array.prototype.push,
slice = Array.prototype.slice,
indexOf = Array.prototype.indexOf;

which is the last lines of the var jQuery = function( selector, context ) {.

No problem if I'm in compatibility view, no problem in any other browsers, just Internet Explorer 9 in Internet Explorer 9 mode and Internet Explorer 9 standards. If I ignore the error I see no problems using any version of jQuery.

What's up, and what I can do to fix?

like image 642
invertedSpear Avatar asked Jun 30 '11 00:06

invertedSpear


2 Answers

The problem was fixed when I removed the SRC attribute from the iframe and I added onOpen event to jQuery's dialog:

open: function()
  {
    document.getElementById("mainFrame").src = "/login.aspx";
  }
like image 80
zarkobehar Avatar answered Oct 30 '22 16:10

zarkobehar


I had the EXACT same issue, but the cause of mine was different. I figured I'd share here in case others were in the same boat as me - especially given that it took me about 4 hours to track down...

Our main page had an iframe which ended up having its src attribute changed twice in a very short amount of time (we were actually loading the same src twice by accident - once directly in the HTML and then again on page load via JavaScript). I'm not sure why Internet Explorer 9 chokes, but I'm guessing that the frame was partially through initializing its scripts when the src was set again, putting the JavaScript engine into an unhappy state. Either way I'm glad I found it, since we shouldn't have been loading the frame twice!

However, the real reason why Internet Explorer 9 died so bad is a mystery.

like image 26
ssawchenko Avatar answered Oct 30 '22 17:10

ssawchenko