[webkit-dev] change the image sources with Javascript

Christian Dywan christian at twotoasts.de
Mon Oct 27 10:11:09 PDT 2008


Am Mon, 27 Oct 2008 13:19:00 +0100
schrieb "Nacho Abejaro" <fantasy54 at gmail.com>:

> Hello, I have a test application that works as a kind of demo
> browser, where I change the source of all images from any HTML page
> using a custom Javascript that I introduce in it through WebKit. My
> Javascript just does that:
> 
> newSource = "file:///c:/test.jpg";
> var images = document.getElementsByTagName("img")
> for (var i=0; i<images.length; i++) {
>     image=images.item(i);
>     image.src = newSource;
> }
> 
> It used to work well, but I've noticed that, after I've compiled it
> with the latest Webkit snapshots, it doesn't work anymore: it does
> change the images src, but the change is not reflected in the
> browser. However, if, instead of an image located in the local disk,
> I choose an image located in a Web server (changing the first line
> by: newSource = " http://anyserver/anyfile.jpg"), it works!
> 
> So, my question is: is there now any kind of restrictions on Webkit
> about directly changing the image sources with Javascript and
> pointing them to local files?

One fundamental resitriction I'm aware of is that you cannot reference
local files from anything else than a local document. That might just
be what you're seeing.

Yours,
    Christian


More information about the webkit-dev mailing list