Jump to content

Recommended Posts

Let me preface this with "I know next to nothing about JavaScript, and usually can't even get a simple, pre-written JS function to run properly".

 

What I'm trying to do is develop a series of HTML templates that provide pseudo-dynamic data on a local machine.

For example, you could write a text file, name it "config.txt" and place it in the same directory as this template, zip it, and email it to me, and i open up the HTML file as a local file, and can view your content.

 

Sample "config.txt"

 

BACKCOLOR FFFFFF;
TXTCOLOR 000000;
:1:
TXT "Hello World! This is a page of text.";
IMG picture.png;
CLICK next [2];

:2:
TXT "This is page 2.";
IMG picture2.png;
CLICK back [1];
CLICK next [3];


 

I guess it is like Powerpoint meets batch files or QBASIC. I know it's a lot of work for something really silly, and if there's an easier way to do it, by all means - let me know. JavaScript is just the only client-side script I know of, and I'm even worse at Flash (IIRC, it has this capability with XML files).

 

The question is, can you (how do you...) import this file with JavaScript, parse it, and somehow make the browser know which content to load. My hopes are to do something like PHP does:

 

<img src="<?=$image;?>">
<a href="<?=$url;?>"><?=$linkText;?></a>
....

 

Any thoughts?

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/236433-read-config-file-on-local-machine/
Share on other sites

As a security measure, you cannot do this with Javascript.  The only thing on your machine Javascript is allowed to read are cookies from the browser's cookie file, based on the domain of the requested page.  In order to do something like this, you will need to write a browser plugin or ActiveX control to act as a proxy between the file and javascript - something the user will have to specifically install or allow to run in the browser.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.