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


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

Getting local img to open window

Started byAndrew Poulos <ap_prog@hotmail.com>
First post2017-07-04 11:26 +1000
Last post2017-07-04 10:21 +0700
Articles 3 — 2 participants

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


Contents

  Getting local img to open window Andrew Poulos <ap_prog@hotmail.com> - 2017-07-04 11:26 +1000
    Re: Getting local img to open window Andrew Poulos <ap_prog@hotmail.com> - 2017-07-04 13:19 +1000
    Re: Getting local img to open window JJ <jj4public@vfemail.net> - 2017-07-04 10:21 +0700

#33572 — Getting local img to open window

FromAndrew Poulos <ap_prog@hotmail.com>
Date2017-07-04 11:26 +1000
SubjectGetting local img to open window
Message-ID<iIGdnXI93plCc8fEnZ2dnUU7-UvNnZ2d@westnet.com.au>
A user can design a question layout (for an elearning web page) and the 
layout can include an image - the user selects the image from their 
local file system. There's a 'preview' button which opens a new window 
showing the the user the layout.

I've started working with FileReader but I have some trouble getting 
things working. I need help with:

- How can I pass the reader result to the new window?

- How can the reader result be used as a CSS background image?
For an img I can do img.src = reader.result but for a background image 
is it just
div.style.backgroundImage = "url('" + reader.result + "')";
?


Andrew Poulos

[toc] | [next] | [standalone]


#33574

FromAndrew Poulos <ap_prog@hotmail.com>
Date2017-07-04 13:19 +1000
Message-ID<dLOdne8FDsjclMbEnZ2dnUU7-N-dnZ2d@westnet.com.au>
In reply to#33572
On 4/07/2017 11:26 AM, Andrew Poulos wrote:
> A user can design a question layout (for an elearning web page) and the 
> layout can include an image - the user selects the image from their 
> local file system. There's a 'preview' button which opens a new window 
> showing the the user the layout.
> 
> I've started working with FileReader but I have some trouble getting 
> things working. I need help with:
> 
> - How can I pass the reader result to the new window?
> 
> - How can the reader result be used as a CSS background image?
> For an img I can do img.src = reader.result but for a background image 
> is it just
> div.style.backgroundImage = "url('" + reader.result + "')";
> ?

Ok, I think I've solved it. I'm now testing/trying

div.style.backgroundImage = "url('"+window.opener.reader.result+"')";


Andrew Poulos

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


#33575

FromJJ <jj4public@vfemail.net>
Date2017-07-04 10:21 +0700
Message-ID<zpyg5dyblcp8$.1hhii9qp5nv8q.dlg@40tude.net>
In reply to#33572
On Tue, 4 Jul 2017 11:26:54 +1000, Andrew Poulos wrote:
> A user can design a question layout (for an elearning web page) and the 
> layout can include an image - the user selects the image from their 
> local file system. There's a 'preview' button which opens a new window 
> showing the the user the layout.
> 
> I've started working with FileReader but I have some trouble getting 
> things working. I need help with:
> 
> - How can I pass the reader result to the new window?
> 
> - How can the reader result be used as a CSS background image?
> For an img I can do img.src = reader.result but for a background image 
> is it just
> div.style.backgroundImage = "url('" + reader.result + "')";
> ?
> 
> Andrew Poulos

Use `readAsDataURL()`.

<https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL>

[toc] | [prev] | [standalone]


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


csiph-web