The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> variable in < OBJECT
crlx2
post 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

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Feb 4 2020, 08:26 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,630
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.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
crlx2
post 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

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Feb 5 2020, 07:44 AM
Post #4


.
********

Group: WDG Moderators
Posts: 9,630
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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
crlx2
post 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!

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 03:37 PM