[Greasemonkey] DOMContentLoaded problem

Linan Wang tali.wang at gmail.com
Thu Oct 5 08:14:31 PDT 2006


The following is the function I wrote:

function call_from_url(url,callback){
    GM_xmlhttpRequest({
        method: "GET",
        url: url,
        onload: function(details){
            // create an IFRAME to write the document into. the iframe must
be added
            // to the document and rendered (eg display != none) to be
property
            // initialized.
            var iframe = document.createElement("IFRAME");
            iframe.style.visibility = "hidden";
            iframe.style.position = "absolute";
            iframe.style.width="1px";
            iframe.style.height="1px";
            document.body.appendChild(iframe);

            // give it 'about:blank' so that it will create a
.contentDocument property.
            iframe.contentWindow.location.href ='about:blank';//
location.href;

            // write the received content into the document
            iframe.contentDocument.open("text/html");
            iframe.contentDocument.write(details.responseText);
            iframe.contentDocument.close();

            // wait for the DOM to be available, then do something with the
document
            iframe.contentDocument.addEventListener("DOMContentLoaded",
function() {
                callback(iframe.contentDocument);
                document.body.removeChild(iframe);
                  }, false);
        }
    });
}

I don't see big difference, while my script runs well.

On 10/5/06, s g <junkvendoremail at yahoo.com> wrote:
>
> just tried it and it still doesn't work.
>
> i replaced the line
>
>     iframe.contentWindow.location.href = location.href;
>
> with
>
>     iframe.contentWindow.location.href ='about:blank';
>
> and later...i'm not seeing the alert.
>
>       iframe.contentDocument.addEventListener("DOMContentLoaded",
> function() {
>         alert('ok');
>
>       }, false);
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Everyone is raving about the  all-new Yahoo! Mail.
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>



-- 
Best regards

Linan Wang


More information about the Greasemonkey mailing list