> > > I have a site that uses aThawtecertification image, but the
> > > image shows up slowly at times thatThawte'sserver is
> > > feeling under the weather.  Since I have no control over
> > > their script or their server-- and since the image's current
> > > position is mid-page--I'd like to be able to just put in a
> > > placeholder and then load it after the rest of the page is
> > > done.  (Presently, it can delay the page's loading.)
>
> > > I've dummied up a couple of pages to show what's happening.
> > > (So far, I've only tested in FF 2.0.0.6.)
>
> > >http://dreamwolf.us/demo/jqscript.php
> > >http://dreamwolf.us/demo/jqscript_button.php

(Note that these two pages may be recommissioned in the future.  See
updated, semi-permanent URL below.)

> > One thing you could do is replace document.write with your own version that
> > uses jQuery or other methods to insert the image dynamically:
>
> >    document.write = function( text ) {
> >       // do your own stuff here
> >    };
>
> > The document.write call at the end would be easy because it's self
> > contained. Just call $(something).append() or the like with that text. The
> > three calls in a row for IE would be a little trickier - you could save the
> > text for each call as you receive it, and then when you get the ending
> > document.write("</div>"); slap them together and do an append() or whatever.

Got it working.  I tried a couple of different things, but here's the
one that finally worked.  In my page, I have a div with a script
descendant:

<div id="thawte"><script type="text/javascript"></script></div>

and the following JavaScript:

$(function() {
        //this line just replaces the entire document with the Thawte image:
        //$('div#thawte > script').attr('src', 'https://siteseal.thawte.com/
cgi/server/thawte_seal_generator.exe');

        //replacement doc.write() for use on closed doc
        document.write = (function () {
                for (var i = 0; i < arguments.length; i++) {
                        $('div#thawte').append(arguments[i]);
                }
        });

        //thawte's script calls doc.write() to do its work; will now append
to the
        //appropriate div instead of replacing the document
        $('#thawte > script').attr('src', 'https://siteseal.thawte.com/cgi/
server/thawte_seal_generator.exe');
});

That may wrap funny, but you can see the working code in my demos
area:

http://dreamwolf.us/demo/thawte.html

Thanks for pointing me in the right direction, Mike.  What I did wrong
in my first attempt:  I tried to "play nice" by replacing the original
document.write() after the call to the thawte script.  However, that
replacement appears to have taken place prior to the completion of the
remote script.  Removing that call solved the issue, but I'm not sure
why, exactly.

Pyro

Reply via email to