JQuery: access to iframe dom from iframe itself

$.fn.resizer = function(o){

    var s = {}
    $.extend(s,o);

    return this.each(function(){

        $(this).css({
            'width':s.width+20,
            'height':s.height+20
        })
            .parent().css({
                'width':s.width,
                'height':s.height
            });

    });

}

I want to do this with an iframe, from inside an iframe.

When I try to call it from there through:

$(top).uploader_finish({
    width:original_width+<?php echo $this->sizes['width'] ?>+20,
    height:original_height+<?php echo $this->sizes['height'] ?>+80
}); 

Getting the parent window, but how to directly access the iframe?

Thank;)

Update

The only solution I found is this:

$ (top.document) .find ('IFrame [name = default_1]');

And the default name is_1, as a parameter of $ _GET, inside the src iframe.

Or is there a way to get the iframe name from the inside?

Update

Aha! Found :)

window.name

So basically it will look like this?

$(top.document).find('iframe[name='+window.name+']');
+5
source share
1 answer

you can get the frame using id

document.getElementById('frameId')

or in the collection window.frames

$(document).find("iframe").attr("name");
+1
source

All Articles