Search code examples
javascriptandroidandroid-2.3-gingerbread

Android 2.3.x browser prepends slash to <image src="


in an app I'm programming I use javascript to add external image references to a site.

So something like this:

<img src="${IMG_URL}" alt="picture"/>

The IMG_URL gets replaced by the javascript and it's content is always in a valid HTTP Request form, like

http://www.domain.de/content/image/324233.jpg

And it works perfectly on every browser (iPhone, iPad and Android 2.2 included). But the Android 2.3.x browser sends a request like this:

GET /http://www.domain.de/content/image/324233.jpg

When I pass an absolute URL the browser always prepends a slash when requesting the image. I even tried to kill the slash with an regex replacement, but it didn't work. If I hardcode the url everything works fine. So it must be the scripts fault.

Since it's a pretty big script (because everything works together you couldn't pick twenty lines and say this is it) it's hard to write down the code for illustration.

I can tell you that the JSON holding the img_url (which comes from a xml) is returned by functions two times and gets finally inserted into the DOM (via jQuery).

Is it possible that somehow the script prepends the slash? But the same script works in Android 2.2 so I really do not have an idea where the problem could be.

I hope you can help somehow.


Solution

  • I found the solution. The browser isn't prepending a slash but the whole domain of the server. So I killed that (before appending to the DOM) with a regular expression and it finally works.

    Still weird that it's prepending it (and only that browser....)