views:

68

answers:

4

Hi

I am trying to use < base> TAG to indicate the source folder containing the media files for my html pages located in separate folder.

I have the following folder structure:

A
|- HTML_PAGES        (contains html files)
|- MEDIA_FOLDER      (contains the media used by this html pages)

I try to indicate the html files with the media used by html pages - so, in each html file i have something like this:

<base href="../MEDIA_FOLDER"/>

And the problem is: it works for some browsers (Opera, Chrome) but it doesn't work for Internet Explorer and Firefox. How to make it work with IE and Firefox?

A: 

Use an absolute URL:

<base href="http://yourdomain.com/MEDIA_FOLDER"/&gt;
Diodeus
Unfortunately, the pages are single html files that refer to the media locally, without web server. Anyway - it might work?
UGEEN
A: 

I'm not sure how BASE works with directory relative urls, try giving it a root relative url like

<base href="/MEDIA_FOLDER"/>
Samuel Cole
That's a root-relative url.
David Thomas
+1  A: 
<base href="../MEDIA_FOLDER"/>

Doesn't have a trailing slash, so it refers to a file called MEDIA_FOLDER and not a folder. Often you don't notice the difference because web servers will redirect an attempt to fetch folder to the proper address folder/, which will then typically return a default document (eg. folder/index.html). But for relative URL resolution it does make a difference.

target relative to /folder is not /folder/target, it's just /target. To make it /folder/target you must let the browser know that the base URL is a folder, by adding a trailing slash:

<base href="../MEDIA_FOLDER/"/>

There is no reason for different browser behaviour here. A place you may find different browser behaviour, though, is if you've accidentally used a Windows-filesystem-style backslash \ instead of /, so do check for that.

bobince
You're right about the trailing slash, but:<base href="../MEDIA_FOLDER/"/> works fine for Opera and Chrome, but not for IE and Firefox.
UGEEN
A: 

Is your base element inside the body element? That could cause the problem. (Check in Firebug, it might end up in the body even if your code looks okay on first sight.)

Ms2ger
my html code:<html><head><base href="../media_folder/"/></head><body><img src="image.jpg"/></body></html>
UGEEN
That looks like it should work. Do you have a link?
Ms2ger
(Uh, I guess you don't.)
Ms2ger