views:

746

answers:

3

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

A: 

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.

Bruce
yes :) that was the first thing I checked. I have jquery 1.3.2 and effects.core.js and effects.shake.js loaded withing the iframe and outside.
Jabes88
A: 

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

Thqr
Well.. While that does make some sort of sense I don't think this is the case.. because I have a div holding the iframe and that div has the ui draggable functionality applied. I am able to drag and drop the iframe around with no problem. The difference here is I set the draggable in a javascript file outside the iframe. I can also shake the iframe from outside but not from within.
Jabes88
How about where the reference is to the JS file. As the Iframe is no longer "supposedly" in the same place if you have subfolders. So maybe have the Iframe page reference as if it was in the page you were using. I'm currently trying to get my head around a similar problem with converting to PHP pages and etc.
Thqr
A: 

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');
});
Nalum