|
-
Jul 30th, 2003, 12:02 PM
#1
(X)HTML: base tag
I want to use the <base> tag for my links. Unfortunatly browsers don't seem to accept relative URLs in the href attribute:
<base href="../" />
I don't want to specify an absolute URL as the page will not always be in the same location. Any way to accomplish the effect with a relative URL?
Thanks in advance
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 5th, 2003, 08:30 AM
#2
Fanatic Member
what does the base tag do
-
Aug 5th, 2003, 10:36 AM
#3
The base tag sets the URL to which all relative URLs in the page relates.
Example
Code:
<html>
<head>
<base href="http://www.vbforums.com/" />
<link rel="stylesheet" type="text/css" href="styles/someone.css" charset="UTF-8" />
...
Would make the stylesheet be
http://www.vbforums.com/styles/someone.css
no matter where the page is located.
What I want is to set a relative URL so that in a directory tree like this:
Code:
/webroot/subdir
/webroot/subdir/styles
/webroot/subdir/styles/tutorial
/webroot/subdir/tutorial
that I can reference the stylesheet in styles like
styles/basic.css
no matter where in the directory the html file actually resides, just by adjusting the base tag.
Here are the problems:
1) I can't place the whole thing in the webroot. There is always one or more subdirs which might even change name.
2) The files are now on my local server, but I will later upload them somewhere else.
Because of 1 I cannot use
/styles/basic.css
and because of 2 I cannot use an absolute URL for the href in the base tag.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 5th, 2003, 11:52 AM
#4
According to the HTML spec:
This attribute specifies an absolute URI that acts as the base URI for resolving relative URIs.
(emphasis mine)
xml:base doesn't seem to have such a restriction, but xml-base probably only works with XLink...
I think your best option is to use an absolute base url, and simply replace-in-all-files when you move the site. Or, you just have to type ../ every time.
-
Aug 6th, 2003, 01:16 AM
#5
xml:base either only works with xlink or xinclude or it is simply not supported by Moz.
I knew about that bit of the spec, I'm looking for some alternative.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 6th, 2003, 08:59 AM
#6
I don't think there is another alternative.
The only other thing I can think of is an xsl stylesheet that adds ../ to all relative urls.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|