still problem with script and variable |
still problem with script and variable |
crlx2 |
Jan 14 2020, 04:58 PM
Post
#1
|
Group: Members Posts: 6 Joined: 14-January 20 Member No.: 27,121 |
Sorry for my indecision to express my problem:
this works: <script src="../clients/code.js"></script> but this doesn't work: var FileName="../clients/code.js"; <script src="+FileName+"></script> I'm not expert to understand the error, but i need to use a variable thank you |
Christian J |
Jan 14 2020, 05:36 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
but this doesn't work: var FileName="../clients/code.js"; <script src="+FileName+"></script> You can't use javascript code outside a SCRIPT element like that. QUOTE I'm not expert to understand the error, but i need to use a variable What is the variable's value? The URL of the javascript file, or the file's contents, or the file itself? If it's just the URL, you might do something like: CODE <script type="text/javascript" id="foo"></script> <script type="text/javascript"> var url="../clients/code.js"; document.getElementById('foo').src=url; </script> (note that you can't both use an URL and embedded javascript code in the same SCRIPT element, hence the need for two SCRIPT elements). |
crlx2 |
Jan 14 2020, 06:22 PM
Post
#3
|
Group: Members Posts: 6 Joined: 14-January 20 Member No.: 27,121 |
god bless you ! it works, it's just what i was looking for!
thanks a lot Christian |
Christian J |
Jan 14 2020, 06:30 PM
Post
#4
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
You're welcome!
|
Lo-Fi Version | Time is now: 26th April 2024 - 03:54 AM |