473,609 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Absolut/relative path using <base> tag

2 New Member
Hello everybody,
I am new so this is the occasion to say hello to everybody.
I have a problem with absolute/relative paths. I have to create a static documentation in html for a project and I have to create an index page in every sub-directory. The structure is like the following:

/
/sources/
/docs/
/docs/doc1
/share

So, in the "share" dir I have the style sheets, images, etc. common to all pages. I thought to use the <base> tag to avoid relative paths in href for images or style sheets. I.e., in the index.html in "sources" dir:

<head><base href="../" /></head>
...
<img href="share/img1.png" />

This could allows me to copy the index.html file in the "docs/doc1" directory or whatever dir and change only the base tag to point to the root direcotry of the project.

This not works for me. The only way is to specify the absolute path like

<base href="file:///absolute_path" />

or

<base href="http:///website" />

Why I cannot specify the base address as relative to the current directory? Thanks in advance.

Yan
Nov 16 '06 #1
3 12843
AricC
1,892 Recognized Expert Top Contributor
Lets say you have these folders in your directory:

/images
/styles
/content
In your main index page you would access them like so "images/xxx.jpg" if you were in content and you wanted to to access images you would do something like "../images/xxx.jpg"

Here is a link if you don't follow what I am saying.

HTH,
Aric
Nov 16 '06 #2
yan
2 New Member
Thank you for your response. But what I try to do is the following. If I have the index.html under the /docs dir for example, it can refers to objects under the /share dir by using href="../share/xxx.jpg". Since I want to use an index.html for every directory if I copy the index.html page from /docs to /docs/doc1 I have to change all the referencies to href="../../share/xxx.jpg and this would be repeated for every reference in the file.

It would be more convenient if I could specify the base tag once on the top of the index.html. I.e., for the index.html in the /docs/doc1 dir I would add <base href="../" /> and let unchanged all the references coming from the file copyed from the /doc dir.

Y.
Nov 17 '06 #3
AricC
1,892 Recognized Expert Top Contributor
What index page are you using for every directory all you need is a blank html page named index this prevents people from seeing the contents of the directory. You really don't need to use the base tag lets say you have
Expand|Select|Wrap|Line Numbers
  1. <base href=http://www.somewebsite.com/index.htm>
And you have some images
Expand|Select|Wrap|Line Numbers
  1. <img src="images/xxx.jpg">
This would make the image url http://www.somewebsite.com/images.jpg you can do the same with paths and leave out the base tag.
Nov 17 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
9204
by: Weston C | last post by:
I'm trying to get the href attribute from the base tag in the document head. The following does not seem to work... any ideas what I'm doing wrong? if(!(document.getElementsByTagName) || !(basehrefs = document.getElementsByTagName('base')) || !(basehrefs.length) || !(basehrefs.length > 0) || !(basehrefs.getAttribute) || !(basehref = basehrefs.getAttribute('href')) )
1
17590
by: Michael | last post by:
In HTML, I would like the base tag... <base href="http://myserver/dir1/"> ....to affect an embedded image src property with a relative path.. <img src="dir2/myimage.jgp"> ....such that the image would be fetched from... "http://myserver/dir1/dir2/myimage.jpg" Why doesn't the base tag work for this? Is there another tag that does?
0
1417
by: Ly Lam | last post by:
In my .resx file (below) I wish to reference an external bitmap that is located in my project's folder. When I try to compile the project I get an error on my .resx file: Resource transformation for file 'Images.resX' failed. Could not find file "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\TEditButton.bmp". It seems like the resource compiler has a base-path set to the vs.net's IDE directory. How do I specify a...
2
1936
by: CD | last post by:
Is this possible: class base; class derived; //:public base vector <base*> bList; vector<derived*> dList; //add some derived class pointer entries to dList;
2
2096
by: Siemel Naran | last post by:
This code fails compile std::auto_ptr<Base> f() { std::auto_ptr<Derived> out(new Derived()); return out; } There is ambiguity between a templated constructor and templated operator conversion, according to my compiler. Seems there are too many constructors and operator conversions. But this code works:
3
4580
by: SJ | last post by:
Hi, I have a problem with the HTML <base> element, URL re-writing and Postback. We are using URL re-writing on the server, and I'd like to use the base element to make the URLs in the ASPX pages more maintainable. Otherwise, we have to manually output the application root eg. src="<%= AppRoot %>". This is cumbersome and hard to maintain. However, there seems to be no way - apart from a client-side script - to rewrite the action...
8
34610
by: Subra Mallampalli | last post by:
Hi, I am trying to use <runtime> section within the web.config file. However, the contents of the <runtime> section seem to be ignored. What am i missing here? Is <runtime> section not used by web apps? Any help is greatly appreciated. Thanks,
0
1485
by: emma_middlebrook | last post by:
Hi Hopefully the title is quite accurate but here's some more information. I have a load of ICollection<references hanging off a class e.g. ICollection<X>, ICollection<Yetc etc. Each of the collection's types are all derived from a base class Base i.e X : Base, Y : Base etc etc.
16
2386
by: call_me_anything | last post by:
why is the following not allowed : vector <Base *vec_of_base; vector <Derived *vec_of_derived; vec_of_base = vec_of_derived; Note : The following is allowed :
0
8115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8557
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8513
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8205
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5504
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.