Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #26547
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: dynamic function |
| Date | 2015-01-11 17:41 +0100 |
| Organization | Liberty Development |
| Message-ID | <m8u93u$2f22$1@adenine.netfront.net> (permalink) |
| References | <54b297d6$0$2961$e4fe514c@news.xs4all.nl> |
Luuk wrote:
>
>
> I have jsHandler.js (found on the internet) with this:
> function include(filename)
> {
> var head = document.getElementsByTagName('head')[0];
>
> script = document.createElement('script');
> script.src = filename;
> script.type = 'text/javascript';
>
> head.appendChild(script)
> }
>
> I have a file called testje.js with this:
> function testje() {
> document.write('testje');
> }
>
>
> My html looks like this:
> <!DOCTYPE html>
> <html>
> <head>
> <title>testje</title>
>
> <script src="jsHandler.js"></script>
> <script>
> include('testje.js');
> </script>
> <body onload='testje();'>
> </body>
> </html>
>
>
> IE complains about 'testje' is undefined.
Which version of IE?
> What i want is to be able to execute the call the function 'testje',
> which is defined inside the 'testje.js'
Why can't you use
<script src="testje.js"></script>
?
And why do you use "createElement" and "appendChild" in one function to
create elements to then try to call a function "onload" that does a
"document.write", which would overwrite the existing document? That all
does not make sense to me.
If you want to call a function loaded by a dynamically created and
inserted "script" element you might be better off to set up a "load"
event listener on that "script" element and call any function in the
event listener.
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
dynamic function Luuk <luuk@invalid.lan> - 2015-01-11 16:33 +0100
Re: dynamic function Martin Honnen <mahotrash@yahoo.de> - 2015-01-11 17:41 +0100
Re: dynamic function Luuk <luuk@invalid.lan> - 2015-01-11 21:20 +0100
Re: dynamic function Martin Honnen <mahotrash@yahoo.de> - 2015-01-12 10:41 +0100
Re: dynamic function Luuk <luuk@invalid.lan> - 2015-01-12 20:44 +0100
Re: dynamic function JJ <jj4public@vfemail.net> - 2015-01-12 02:01 +0700
csiph-web