Dave Methvin schrieb:
> The #id notation in a selector always uses document.getElementById; in your
> case it's the wrong document (the document that contains the iframe, not the
> document of the iframe). One workaround would be to select the object
> manually when you create the jQuery object,
> $(window.frames[iframeName].document.getElementById(iframeElement)), and I
> agree it's ugly. Another shorter(text)/longer(runtime) way would be to use
> the general attribute syntax, $("[EMAIL PROTECTED], iframeDoc).
> If you do the latter, it will be more efficient to use the actual tag type
> (e.g, [EMAIL PROTECTED]) rather than *, which requires looking at every 
> element
> in the iframe.
>   
I'm just wondering if we could implement an at least 
not-that-slow-if-used-often approach to simulate getElementById eg. on 
XML docs. The basic idea would be to get all elements once and store 
them in an object by their id, eg:
var idCache = {};
$("*", document).each(function() {
    if(this.id)
        idCache[this.id] = this;
});
A "simulated" getElementById could then just be:
function(id) {
    return idCache[id];
}

It would be fast and reliable if used more then once, or rather, used 
often and if the document doesn't change. Therefore quite useful to 
query XML documents.

Any ideas if and how this could be implemented to be more useful?

-- 
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to