[Javascript] Loading Problem

Tim Makins spindrift at oceanfree.net
Wed Sep 15 06:12:59 CDT 2004


David - What format should 'address' be ? I just tested it with
'gaz/table.js' on Internet Explorer, and for the line:

script.setAttribute.src=address;

I get the error 'Object doesn't support this property or method'.

Tim in Ireland.

----- Original Message ----- 
From: "liorean" <liorean at gmail.com>
To: "[JavaScript List]" <javascript at latech.edu>
Sent: Wednesday, September 15, 2004 11:35 AM
Subject: Re: [Javascript] Loading Problem


> On Wed, 15 Sep 2004 10:53:07 +0100, Tim Makins <spindrift at oceanfree.net>
wrote:
> > Today's question:
> > My table-viewer uses a number of data-files, such as the above (a
shortened
> > version). It is stored as 'table_uscount1.js', and will be loaded by
> > including the line:
> >
> > <script src="gaz/table_uscount1.js"></script>
> >
> > at the top of the page that processes it. However, if there are a lot of
> > these files, the 'load' gets very big and takes time. Is there a way to
only
> > load the one I want, when it is asked for ??
>
> Yes there is. However, if you want saf and iem support on the Mac it's
> gonna be a long winded one. Also, op didn't support this before
> version 7.5. I've not tested doing this on shiira or omniweb, so I
> will not even bother with coding for them right now.
>
> function loadScript(address){
>     var
>         m=/mac/i.test(navigator.platform),
>         a=window.ActiveXObject||false,
>         x=window.XMLHttpRequest||false,
>         s=/apple/i.test(navigator.vendor),
>         script;
>     // First we do the op7.5/moz/iew solution.
>     // No feature detection necessary, all other browsers will just
> gracefully fail.
>
(script=document.createElement('script')).setAttribute('type','text/javascri
pt');
>     script.setAttribute.src=address;
>     document.getElementsByTagName('head').item(0).appendChild(script);
>     // Okay, that done. How about iem, then?
>     if(m&&a)
>         document.createElement('div').innerHTML='<script
> type="text/javascript" src="'+address+'"><\/script>';
>         // You don't even have to insert it into the document!
>     // Okay, saf left.
>     if(m&&s){
>         x.open('GET',address,false);
>         x.send(null);
>         eval(x.responseText);
>     }
> }
> -- 
> David "liorean" Andersson
> <uri:http://liorean.web-graphics.com/>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>




More information about the Javascript mailing list