![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I need to be able to conditionally load a remote script, using the "<script src=..." syntax. Or some other way. |
|
I've seen people writing about using the document.write method, but it's not working like I want it to. If I look at the source of the page in this state, all I see is the script tag I've document.written. |
#3
| ||||
| ||||
|
|
"Razzbar" wrote I need to be able to conditionally load a remote script, using the "<script src=..." syntax. Or some other way. That syntax would not be reliable in a contional way. Try this: if ( foo ) { var bar = document.createElement('script'); bar.src = 'mypath/myscript.js'; document.body.appendChild(bar); } |
|
I've seen people writing about using the document.write document.write() should only be used during the initial load of the page, if |
|
at all. Upon loading, the document is closed and writing to it would result in a new document being generated. This is what you see in the source. |
|
HTH |
#4
| |||
| |||
|
|
"Ivo" <no (AT) thank (DOT) you> wrote "Razzbar" wrote I need to be able to conditionally load a remote script, using the "<script src=..." syntax. Or some other way. That syntax would not be reliable in a contional way. Try this: if ( foo ) { var bar = document.createElement('script'); bar.src = 'mypath/myscript.js'; document.body.appendChild(bar); } Thank you! It didn't work, but I added the appendChild line, and it's all hunky-dory. I've seen people writing about using the document.write document.write() should only be used during the initial load of the page, if Besides, I think it's just a hokey kludgey way to do things. IMHO. at all. Upon loading, the document is closed and writing to it would result in a new document being generated. This is what you see in the source. Exactly. It takes forever, then you see a blank page. Worst, you can't reload the original page. Even with a pragma no-cache, if you reload you get the .js file. You just can't get the original page back -- in IE6. Probably browser specific. Too much of that going around. HTH You did. Thanks. |
#5
| |||
| |||
|
|
However, regarding loading of script by setting .src, see the comments regarding Mozilla / Netscape at http://groups.google.com/groups?thre...eda.datanet.hu |
![]() |
| Thread Tools | |
| Display Modes | |
| |