Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #13050 > unrolled thread

javascript

Started bynaveen raj <naveenrajp.erode@gmail.com>
First post2012-03-25 00:29 -0700
Last post2012-03-25 07:03 -0700
Articles 5 — 5 participants

Back to article view | Back to comp.lang.javascript


Contents

  javascript naveen raj <naveenrajp.erode@gmail.com> - 2012-03-25 00:29 -0700
    Re: javascript SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-03-25 11:10 +0200
      Re: javascript "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-25 16:00 +0000
      Re: javascript Dr J R Stockton <reply1213@merlyn.demon.co.uk.not.invalid> - 2012-03-26 20:44 +0100
    Re: javascript Scott Sauyet <scott.sauyet@gmail.com> - 2012-03-25 07:03 -0700

#13050 — javascript

Fromnaveen raj <naveenrajp.erode@gmail.com>
Date2012-03-25 00:29 -0700
Subjectjavascript
Message-ID<31677fea-c30c-4bd3-9735-3aefe08f174d@z3g2000pbn.googlegroups.com>
how to read from a file in the script ?

[toc] | [next] | [standalone]


#13052

FromSAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid>
Date2012-03-25 11:10 +0200
Message-ID<4f6ee117$0$12526$ba4acef3@reader.news.orange.fr>
In reply to#13050
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

example

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;
document.body.appendChild(s);
}

not sure that works with IE

-- 
Stéphane Moriaux avec/with iMac-intel

[toc] | [prev] | [next] | [standalone]


#13057

From"Evertjan." <exjxw.hannivoort@interxnl.net>
Date2012-03-25 16:00 +0000
Message-ID<XnsA021B721DFB68eejj99@194.109.133.133>
In reply to#13052
SAM wrote on 25 mrt 2012 in comp.lang.javascript:

> Le 25/03/12 09:29, naveen raj a Drit :
>> how to read from a file in the script ?
> 
> not possible

Not possible in clientside Javascript on a security compliant browser.

However there are other ways of using javascript,
like serverside on an ASP platform,
or using cscript or wscript, 
or inside localy used programmes. 

In all these, reading a file is very possible.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#13073

FromDr J R Stockton <reply1213@merlyn.demon.co.uk.not.invalid>
Date2012-03-26 20:44 +0100
Message-ID<KeRNu2DNcMcPFwmd@invalid.uk.co.demon.merlyn.invalid>
In reply to#13052
In comp.lang.javascript message <4f6ee117$0$12526$ba4acef3@reader.news.o
range.fr>, Sun, 25 Mar 2012 11:10:47, SAM <stephanemoriaux.NoAdmin@wanad
oo.fr.invalid> posted:

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

I do it, literally almost every day.  Shortly after 18:00 LCT for one
reason, and irregularly for others.

With a browser, an HTML or TXT file (and maybe other types) from the
same domain (including the local disc (except in Chrome (unless they've
recently fixed it))) into an iframe element and its content can then be
accessed.  An HTML file just adds to the DOM tree as a branch; a TXT
file as a string.

  // Ifr is a reference to the iframe:
  FILE = Ifr.contentDocument.body
  FILE = FILE.textContent || FILE.innerText // IE8 needs latter
  // FILE is now a string.

This newsgroup is not solely for Web authoring or using browsers like
Firefox.  It also covers MS IE, in which a .HTA file can access the
local disc in full with VBscript or JScript, with a Web-like display.
It also covers Windows Scripting Host, in which a script can access the
local disc in full with VBscript or JScript, with a Command Prompt
display.  It also covers anything that may be equivalent in Mac, UNIX,
or other non-Windows systems.

But, in a Web page, one cannot read the innards of anything other than
same-domain material - AFAIK, it's not allowed and should not be
possible.

-- 
 (c) John Stockton, Surrey, UK.  ?@merlyn.demon.co.uk   Turnpike v6.05   MIME.
   Web  <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
 Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
 Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)

[toc] | [prev] | [next] | [standalone]


#13054

FromScott Sauyet <scott.sauyet@gmail.com>
Date2012-03-25 07:03 -0700
Message-ID<934e71b8-8100-4c9c-8fec-4ebfa9ff24a1@w1g2000vbx.googlegroups.com>
In reply to#13050
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web