2012-06-27 4 views

ответ

6

При условии, что доступ кадр не ограничивается одной и той же политики происхождения:

function getElem(selector, $root, $collection) { 
    if (!$root) $root = $(document); 
    if (!$collection) $collection = $(); 
    // Select all elements matching the selector under the root 
    $collection = $collection.add($root.find(selector)); 
    // Loop through all frames 
    $root.find('iframe,frame').each(function() { 
     // Recursively call the function, setting "$root" to the frame's document 
     getElem(selector, $(this).contents(), $collection); 
    }); 
    return $collection; 
} 
// Example: 
var $allImageElements = getElem('img'); 
Смежные вопросы