Justin Bull
Justin Bull

Reputation: 8215

jQuery effect on iframe parent document

Just wondering if anyone else has experienced this or knows why I am getting an error. I'm using javascript from within an iframe to call a parent dom element then use jQuery UI's effect core to shake it. Here is an example:

$(document).ready(function(){
    if ($("form").length>0)
    {
        $("form").submit(function(){
            var oParentDoc = $(parent.document).find("div#element");
            var action = $(this).attr("action");
            var postdata = $(this).serialize();
            $(oParentDoc).addClass("loading");
            $.post(action,postdata,function(data){
                $(oParentDoc).removeClass("loading").effect("shake",{"times":3,"distance":10},60);
            });
            return false;
        });
    }
});

It works without the effect, but when I use an effect it gives me this error:

uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMCSSStyleDeclaration.getPropertyValue]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"

Thanks in advance for any insight :)

Upvotes: 1

Views: 6294

Answers (3)

Nalum
Nalum

Reputation: 4213

I'm not sure if this will work but you could try setting up a bind event in the parent, then in the iFrame try triggering that event in the parent.

Parent JavaScript

$(document).ready(function(){
    $('#iframe').bind('shakeFrame',function(){
        $('#iframe').effect("shake",{"times":3,"distance":10},60);
    });
});

iFrame JavaScript

$(document).ready(function(){
    $(parent.document).find('#iframe').trigger('shakeFrame');
});

Upvotes: 1

Bruce
Bruce

Reputation: 8430

Have you loaded the necessary jQuery files into the parent document as well as the iframe document?

UPDATE: A little research on the internet indicates that the 'effect' code is probably calling 'getPropertyValue' and Firefox is claiming that method doesn't exist. I know - not very helpful. Unfortunately I believe you're going to have to debug the 'effect' code to find out more specifically whose bug this is, or perhaps find that its a limitation of the iframe scenario you're trying to run.

Upvotes: 0

Sphvn
Sphvn

Reputation: 5353

It could be that your Iframe's specifications are defined. Therefore not allowing any movement / change with the Iframe?

Upvotes: 0

Related Questions