Velocity Reviews

Velocity Reviews (
-   Javascript (
-   -   javascript (

naveen raj 03-25-2012 07:29 AM

how to read from a file in the script ?

SAM 03-25-2012 09:10 AM

Re: javascript
Le 25/03/12 09:29, naveen raj a écrit :
> how to read from a file in the script ?

not possible

you must pass the text "to read" in a variable

then you can try to get the file


file to read : 'txt_1.js'
var t = 'Hello World';

reading :
<button onclick="newText('txt_1.js'); alert(t);">read 1</button>

function newText(url) {
var s = document.createElement('SCRIPT');
s.src = url;

not sure that works with IE

Stéphane Moriaux avec/with iMac-intel

Scott Sauyet 03-25-2012 02:03 PM

Re: javascript
naveen raj wrote:
> how to read from a file in the script ?

Can you clarify what you're trying to do? The security policy of
browsers make it difficult if not impossible to read a file from the
user's local machine. But server-side scripts, and some browser
techniques can allow for it. Moreover, there are easy ways to read
from URLs on the same domain as a web page. Those URLs often map to
server-side files.

So what is it you're after?

-- Scott

All times are GMT. The time now is 11:08 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.