How to dynamically change the source of an image for delayed loading?

16 views
Skip to first unread message

Serge

unread,
May 6, 2016, 12:57:54 PM5/6/16
to brython
I have an HTML page with a placeholder for a large image which should be loaded only when the rest of a Brython script finishes.

<img alt="large map" id="large_map" />

Selecting the image by id is easy enough, but then how do I go about changing its src option?
I am having no luck with the options collection associated with a SELECT object.

<script type="text/python">
from browser
import document
doc
['large_map'].???
</script>


Kiko

unread,
May 6, 2016, 1:46:25 PM5/6/16
to bry...@googlegroups.com
Hi Serge,

See an example here: http://jsfiddle.net/rwq83gpj/
When you click the button, after 3 secs it will appear the image.

I hope it helps.

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/b21d89f9-f4fd-4e62-8517-772430b12e2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kiko

unread,
May 6, 2016, 1:49:38 PM5/6/16
to bry...@googlegroups.com
2016-05-06 19:46 GMT+02:00 Kiko <kikoco...@gmail.com>:


2016-05-06 18:57 GMT+02:00 Serge <stoo...@gmail.com>:
I have an HTML page with a placeholder for a large image which should be loaded only when the rest of a Brython script finishes.

<img alt="large map" id="large_map" />

Selecting the image by id is easy enough, but then how do I go about changing its src option?
I am having no luck with the options collection associated with a SELECT object.

<script type="text/python">
from browser
import document
doc
['large_map'].???
</script>


Hi Serge,

See an example here: http://jsfiddle.net/rwq83gpj/
When you click the button, after 3 secs it will appear the image.

I hope it helps.

Sorry, the previous link is wrong. This one should work: http://jsfiddle.net/rwq83gpj/1/

Serf

unread,
May 6, 2016, 2:03:34 PM5/6/16
to brython
Your jsfiddle image still does not show up, however its source was all I needed to make my case work.
Thanks! The select Brython community is a great community!

Kiko

unread,
May 6, 2016, 2:07:34 PM5/6/16
to bry...@googlegroups.com
2016-05-06 20:03 GMT+02:00 Serf <stoo...@gmail.com>:
Your jsfiddle image still does not show up, however its source was all I needed to make my case work.

Strange, I've tested again and it is working for me... (after 3 secs).
 
Thanks! The select Brython community is a great community!

Yes it is.
 

On Friday, 6 May 2016 19:49:38 UTC+2, kiko (on pybonacci) wrote:


Sorry, the previous link is wrong. This one should work: http://jsfiddle.net/rwq83gpj/1/

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.

Nicolas Pinault

unread,
May 6, 2016, 4:04:50 PM5/6/16
to bry...@googlegroups.com
Le 06/05/2016 à 20:07, Kiko a écrit :


2016-05-06 20:03 GMT+02:00 Serf <stoo...@gmail.com>:
Your jsfiddle image still does not show up, however its source was all I needed to make my case work.

Strange, I've tested again and it is working for me... (after 3 secs).
I've had the same problem but found a workaround.
Looking at the console, the loading of Brython is blocked because of mixed content. Please see here for more information : https://developer.mozilla.org/en-US/docs/Security/Mixed_content
The link you gave is http://jsfiddle.net/rwq83gpj/1/ . On my system, it is automatically converted to https://jsfiddle.net/rwq83gpj/1/ (note the use of https). This is because I have the HTTPSEverywhere extension activated (Firefox).
The workaround is to deactivate HTTPSEverywhere and reload the page in http mode.

Nicolas

Kiko

unread,
May 6, 2016, 4:07:21 PM5/6/16
to bry...@googlegroups.com
Good to know!!

Thanks, Nicolas.

 
Nicolas

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.

Serf

unread,
May 7, 2016, 11:08:58 AM5/7/16
to brython
Smart!
I can confirm that I am also running HTTPSEverywhere.
Reply all
Reply to author
Forward
0 new messages