Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to Read a .txt file on server using Java?

Engaged ,
Mar 06, 2017 Mar 06, 2017

Hello

Cap9. HTML5 only. Server=Linux(LAMP). No LMS.

I have a text file on the server named golive.txt which contains a single item of text, either the letter "Y" or "N".

When the Captivate project starts I need the project to read the text file.

If the text is "Y" I need a button in Captivate to be shown.

How can I do this?

I assume I will have to use Execute Javascript when the project starts.

I looked on the internet for Javascript examples of how to read a text file from a server, but they all seem to be too complicated, (arrays, libraries, etc), for such a simple need.

I don,t need to check for the file, it will be there.

I don't need to write to the file.

I don't need to display the contents.

Any help or suggestions will be much appreciated.

Thank you

Peter.

676
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Mar 06, 2017 Mar 06, 2017

I figured it out.

Put on a Web Object pointing to golive.txt

Use Java to get the content of Web Object.

    var myIFrame = document.getElementsByTagName("iframe")[0];

    var content = myIFrame.contentWindow.document.body.innerHTML;

     alert(content);

Translate
Engaged ,
Mar 06, 2017 Mar 06, 2017

I had a thought.

If I use a Web Object to view the golive.txt file, I will have the text on a slide.

How can I read the content of the Web Object in Java?

Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 06, 2017 Mar 06, 2017
LATEST

I figured it out.

Put on a Web Object pointing to golive.txt

Use Java to get the content of Web Object.

    var myIFrame = document.getElementsByTagName("iframe")[0];

    var content = myIFrame.contentWindow.document.body.innerHTML;

     alert(content);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources