jQuery effect on iframe parent document

1

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 :)

javascript
jquery
iframe
parent
effect
asked on Stack Overflow Feb 2, 2010 by Justin Bull • edited Feb 2, 2010 by Justin Bull

3 Answers

1

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');
});
answered on Stack Overflow May 26, 2010 by Nalum
0

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.

answered on Stack Overflow Feb 2, 2010 by Bruce • edited Feb 3, 2010 by Bruce
0

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

answered on Stack Overflow Feb 2, 2010 by Sphvn

User contributions licensed under CC BY-SA 3.0