variable in < OBJECT |
variable in < OBJECT |
crlx2 |
Feb 4 2020, 06:34 PM
Post
#1
|
Group: Members Posts: 6 Joined: 14-January 20 Member No.: 27,121 |
i need to show the text contained in a text file, so i used this html line:
<object id="file1" data="file1.txt"></object> what i am not able to do is: how to use a variable instead of the string "file1.txt" ? thanks |
Christian J |
Feb 4 2020, 08:26 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
I think you could change the value of the DATA attribute with e.g.:
CODE <button onclick="document.getElementById('file1').setAttribute('data','file2.txt');">... but Firefox appears to be buggy. |
crlx2 |
Feb 5 2020, 04:14 AM
Post
#3
|
Group: Members Posts: 6 Joined: 14-January 20 Member No.: 27,121 |
Dear Chistian J
i was not able to let it work (in chrome) on setattribute i get an error: TypeError: Cannot read property 'setAttribute' of null |
Christian J |
Feb 5 2020, 07:44 AM
Post
#4
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
Could you post a sample of it?
Another solution might be to use server-side scripting (e.g. PHP) to read the text file, then browser support isn't an issue. |
crlx2 |
Feb 5 2020, 11:06 AM
Post
#5
|
Group: Members Posts: 6 Joined: 14-January 20 Member No.: 27,121 |
Hi Christian
I understood that these things are too far from my competences and i gave up and found a work around with winsock, thanks a lot for you kind help! |
Lo-Fi Version | Time is now: 25th April 2024 - 10:25 PM |