Connecting Tech Pros Worldwide Help | Site Map

set iframe src to file input value?

Chris Riesbeck
Guest
 
Posts: n/a
#1: Sep 9 '08
I assume the answer to this is "no" with no workarounds, but just checking.

I have a page I open locally from my filesystem for "scrubbing"
Microsoft Word generated junk from HTML. In Firefox 2, I could simply
click on a Browse button to pick a file. The Javascript would set the
SRC of an IFRAME to that file (mangled to file: form), get the content,
scrub it, and dump the output in another window for saving.

In Firefox 3, this doesn't work because FILE INPUT value is just the
file name, e.g., foo.html, not the entire path. I understand why this is so.

I tried giving my HTML file UniversalBrowserRead capability, though I
may have done that wrong. It didn't help. Should that work? Is there an
alternative? Or am I back to the older interface where I to copy and
paste the HTML manually from a text editor?
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#2: Sep 9 '08

re: set iframe src to file input value?


Chris Riesbeck wrote:
Quote:
In Firefox 2, I could simply click on a Browse button to pick a file. The
Javascript would set the SRC of an IFRAME to that file (mangled to file:
form), get the content, scrub it, and dump the output in another window
for saving.
>
In Firefox 3, this doesn't work because FILE INPUT value is just the file
name, e.g., foo.html, not the entire path. I understand why this is so.
>
I tried giving my HTML file UniversalBrowserRead capability, though I may
have done that wrong.
You need to set the pref `signed.applets.codebase_principal_support'
to `true' (default is `false') for privilege requests to work. Then

netscape.security.PrivilegeManager.enablePrivilege ("UniversalBrowserRead")

does not throw an exception. But it does not seem to help with the `value'
property either, nor does attempting to get any other privilege.
Quote:
It didn't help. Should that work?
Apparently not.
Quote:
Is there an alternative?
A) Using input.files[0].getAsText("target-encoding") to set
iframe.contentDocument.body.textContent and the like. Turns out you
can even use getAsBinary() or getAsDataURI() without requesting
any privileges. That's quite a security logic, isn't it?

B) Submitting a bug report, or voting on an existing bug that targets this
pointless misbehavior.
Quote:
Or am I back to the older interface where I to copy and
paste the HTML manually from a text editor?
Unlikely, although I consider this crippling input[type=file] and even XHR
beyond use for scripting a major bug. There is no good reason why that
needs to be, especially not security: from my filesystem, I should be
allowed to do everything that the OS permissions of my user account would
allow me to do.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>
SAM
Guest
 
Posts: n/a
#3: Sep 9 '08

re: set iframe src to file input value?


Chris Riesbeck a écrit :
Quote:
I assume the answer to this is "no" with no workarounds, but just checking.
>
I have a page I open locally from my filesystem for "scrubbing"
Microsoft Word generated junk from HTML. In Firefox 2, I could simply
click on a Browse button to pick a file. The Javascript would set the
SRC of an IFRAME to that file (mangled to file: form), get the content,
scrub it, and dump the output in another window for saving.
>
In Firefox 3, this doesn't work because FILE INPUT value is just the
file name, e.g., foo.html, not the entire path. I understand why this is
so.
>
I tried giving my HTML file UniversalBrowserRead capability, though I
may have done that wrong. It didn't help.
It's not the alone bug about path of local files in this version of Fx
:-(

--
sm
Closed Thread


Similar JavaScript / Ajax / DHTML bytes