Norks
Norks

Reputation: 410

window.parent.$() doesn't work in IE

I don't understand my snippet below, it works perfectly in chrome (not tested in ff yet) but it has error in IE stating "Invalid argument", Is there any way we can work around this problem?

window.parent.$('#tdDealItem').append($wrap);

Upvotes: 1

Views: 2192

Answers (3)

Callie J
Callie J

Reputation: 31296

I've had the same problem with IE-embedded-in-Silverlight in the form of Silverlight's WebBrowser control.

The fix was a bit off the odd, and I'm not sure I understand why, however, taking my solution and applying it to yours, it's just a case of putting parent.jQuery into it's own variable, i.e.:

var parentjq = parent.jQuery;
parentjq("#tdDealItem").append($wrap);

For some reason, IE-in-SL doesn't like the syntax parent.jQuery(...)., giving me the "Object doesn't support this property of method 'jQuery'".

It's worth noting that this only happened in IE-in-SL: IE running in IE7 browser mode with IE7 strict didn't exhibit the same problem. However YMMV.

For the curious (and completeness), I had the problem/error message with:

var fldid = parent.$("body").data("dateFieldId");

But after splitting into:

var parentjq = parent.jQuery;
var fldid = parentjq("body").data("dateFieldId");

the error went away and I was getting the right results.

Upvotes: 0

EnterJQ
EnterJQ

Reputation: 1014

Try this,

$(w.document.body).$('#tdDealItem').append($wrap);

Upvotes: 0

dsgriffin
dsgriffin

Reputation: 68576

Have you tried taking out the 'window' part and just using parent.$('#tdDealItem').append($wrap);

Upvotes: 1

Related Questions