> I have an ad serving application that give me a chunk of javascript to
> put in each page an when then page it loaded, that javascript executes
> and it load a banner ad.
>
> Basically, I''m returned this from the server:
>
> <script language="JavaScript1.1"
type="text/javascript"
> src="http://mysite.com/execute/this_javascript.js">
> </script>
>
> The question I have is how do I get Ajax.Updater to load this?
I''m
> not sure if onComplete will work and I''m not sure that I can count
on
> the function names in this_javascript.js.
>From my understanding, in every browser not based on Konqueror, you
could do something like:
var script = document.createElement(''SCRIPT'');
script.src = ''/path/to/your.js'';
(that''s probably either incomplete or wrong syntax, as I''ve
never
actually done it, just read about it). However, Safari and other
Konqueror-based browsers don''t support adding scripts dynamically like
that, from what I''ve read. So, you''re basically SOL if you
want to
support them.
As I said, this is based on things I''ve read, never tried myself. So I
could be wrong.
You might be able to do a hack by using an iframe and doing a
document.write to the iframe, but then you''d have to reference the
iframe before every function to use them, as the functions won''t exist
within the namespace of the parent window.
myIframe.function(''blah''); instead of
function(''blah'');
If you have the script name available to you before the page finishes
loading, then you can just do
document.write(''<script>....<\/script>'');
to load it. If the page has already finished loading, that will
overwrite the whole page. Take note that the /script is \/script . It
must be escaped or the browser will read it as the ending tag of your
<script> tag that has the document.write() inside it.
Greg