if the weather widget creates a javascript object in the js namespace, you
can test for that when the page has loaded. you can even try to
re-initialize the weather widget if it fails the first time (but that would
take some doing).

you'd need to include the weather widget in the <head> of your target page.
and assume that the weather widget makes the global js var "weatherWidget"
available.

you could try this;
<head>
  <script language='JavaScript1.3' type='text/javascript' src='
http://somehost.com/widgets/weather_widget.js'></script>
  <script language='JavaScript1.3' type='text/javascript'>
     <!--
    window.onload = function () {
        //call previous window.onload statements here

        var scriptSrc = 'http://somehost.com/widgets/weather_widget.js';
        if (!weatherWidget) {
            var scriptsInHead =
$('script',document.getElementsByTagName("head")[0]);
            var found = false;
            for (var j=0; j<scriptsInHead.length && (!found); j++) {
                if (scriptsInHead[j].src == scriptSrc) found = j;
            }
            var e = document.createElement("script");
            e.type="text/javascript";
            e.language='JavaScript';
            e.src = scriptSrc;
            if (found===false) {
                if (console) console.log ("appending "+e.src+" to HEAD.");
                __htmlHead.appendChild(e);
            } else {
                if (console) console.log ("removing then re-adding "+e.src+"
to HEAD.");
                scriptsInHead[found].parentNode.removeChild
(scriptsInHead[found]);
                __htmlHead.appendChild (e);
            }
        } else {
            //optional:
            weatherWidget.initialize();
        }
        setTimeout (window.onload, 300); //retry in 300 milliseconds
    }
    -->
    </script>
</head>

On Sat, Sep 6, 2008 at 4:20 AM, bcbounders <[EMAIL PROTECTED]> wrote:

>
> OK... I'm new to jQuery (and not much of a JS programmer), so be
> gentle with me!  :D
>
> I have a site that's using a Javascript to embed a small weather
> widget (it's from weather.ibegin.com).  The problem is that  my client
> REALLY likes the look of the iBegin weather widget, but iBegin hasn't
> been that reliable... so sometimes NOTHING shows.
>
> I'd really love to be able to use jQuery to determine if the
> Javascript has successfully loaded the weather and display it if it
> has... but display a static image if the weather didn't load.
>
> Is this possible?  And, if so, how would I go about doing that?
>
> Thanks a lot!
>
>  - John
>

Reply via email to