Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

HTML - BASE attribute to ignore anchor links

 
Thread Tools Search this Thread
Old 03-04-2005, 06:50 AM   #1
Default BASE attribute to ignore anchor links


I have a page with the BASE tag:

<BASE HREF="http://www.server.com/path/page.html">

This works the way I want for src references and links leading away
from my page -- they lead to the BASE url. However, I want anchor
links to go to the anchor name on my page -- not on the BASE page.
Unfortunately, this happens: The following link on my page:

<A HREF="#anchor">link</a>

leads to http://www.server.com/path/page.html#anchor instead of to

<A NAME="anchor">

on my page.

Is there an attribute for the BASE tag that prevents this? Or is
there some other way to prevent it?

--
DTM :<|
www.danfingerman.com


Dan Fingerman
  Reply With Quote
Old 03-04-2005, 12:45 PM   #2
Beauregard T. Shagnasty
 
Posts: n/a
Default Re: BASE attribute to ignore anchor links

Dan Fingerman wrote:

> I have a page with the BASE tag:
>
> <BASE HREF="http://www.server.com/path/page.html">


server.com is a real domain. Please use "example.com" which is
reserved for the purpose.

Since your anchor links work without the base href, why use it? Links
to other pages - either within your site or elsewhere - should also
work without it. I've never been able to find a need for a base href.

--
-bts
-This space intentionally left blank.
  Reply With Quote
Old 03-04-2005, 12:56 PM   #3
Carolyn Marenger
 
Posts: n/a
Default Re: BASE attribute to ignore anchor links

On Fri, 04 Mar 2005 06:50:46 +0000, Dan Fingerman wrote:

> I have a page with the BASE tag:
>
> <BASE HREF="http://www.server.com/path/page.html">
>
> This works the way I want for src references and links leading away
> from my page -- they lead to the BASE url. However, I want anchor
> links to go to the anchor name on my page -- not on the BASE page.
> Unfortunately, this happens: The following link on my page:
>
> <A HREF="#anchor">link</a>
>
> leads to http://www.server.com/path/page.html#anchor instead of to
>
> <A NAME="anchor">
>
> on my page.
>
> Is there an attribute for the BASE tag that prevents this? Or is
> there some other way to prevent it?


I believe the solution you are looking for is:
<base href="http://www.server.com/path/">

When you specify a file in the base statement, all links are going to try
to relate to that file. If you specify the path only, then file links
will relate to the path, however links referring to the current document
should be fine.

Carolyn
  Reply With Quote
Old 03-04-2005, 03:59 PM   #4
Jukka K. Korpela
 
Posts: n/a
Default Re: BASE attribute to ignore anchor links

Carolyn Marenger <> wrote:

>> <BASE HREF="http://www.server.com/path/page.html">

- -
> I believe the solution you are looking for is:
> <base href="http://www.server.com/path/">


It certainly isn't. The two are completely equivalent. If in doubt, check
the HTML specs. If still in doubt, test it.

> When you specify a file in the base statement, all links are going to try
> to relate to that file.


Where did you get such an idea? Everything after the last "/" character in
the href attribute of a base element is ignored. People may still put
something there, since the virtually only sensible use for the construct is
in testing things, when you have copied a document from somewhere and want
to make it behave as on the original server. Then you might just as well
keep the last part of the path (the one that so often gets mapped to a
filename) as a reminder of the exact origin.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


  Reply With Quote
Old 03-04-2005, 09:02 PM   #5
Carolyn Marenger
 
Posts: n/a
Default Re: BASE attribute to ignore anchor links

On Fri, 04 Mar 2005 15:59:47 +0000, Jukka K. Korpela wrote:

> Carolyn Marenger <> wrote:
>
>>> <BASE HREF="http://www.server.com/path/page.html">

> - -
>> I believe the solution you are looking for is:
>> <base href="http://www.server.com/path/">

>
> It certainly isn't. The two are completely equivalent. If in doubt, check
> the HTML specs. If still in doubt, test it.
>
>> When you specify a file in the base statement, all links are going to try
>> to relate to that file.

>
> Where did you get such an idea? Everything after the last "/" character in
> the href attribute of a base element is ignored. People may still put
> something there, since the virtually only sensible use for the construct is
> in testing things, when you have copied a document from somewhere and want
> to make it behave as on the original server. Then you might just as well
> keep the last part of the path (the one that so often gets mapped to a
> filename) as a reminder of the exact origin.


Thank you for the correction.

Carolyn
  Reply With Quote
Old 03-07-2005, 02:52 AM   #6
Dan Fingerman
 
Posts: n/a
Default Re: BASE attribute to ignore anchor links

Beauregard T. Shagnasty wrote at Fri 04 Mar 2005 04:45:10, in
<news:>:

> Dan Fingerman wrote:
>
>> I have a page with the BASE tag:
>>
>> <BASE HREF="http://www.server.com/path/page.html">

>
> server.com is a real domain. Please use "example.com" which is
> reserved for the purpose.


Noted for the future -- thanks for the tip.


> Since your anchor links work without the base href, why use it?
> Links to other pages - either within your site or elsewhere -
> should also work without it. I've never been able to find a need
> for a base href.


A group I work with frequently saves web pages from a particular site
to a local drive and share them via email. All the href and src tags
and the css references in these pages are relative, not absolute. We
want the img src tags and links to work properly when we load the
pages we have stored locally (that is, we want them to reference the
site from which the page was saved), but we want the anchor tags to
point to the local page we have saved.

I thought the easiest way to accomplish this would be to add a base
tag to the header of each file. However, this makes the anchor links
also point to the path specified in the base tag, rather than to the
page saved locally.

The next easiest way to accomplish what we want seems to be to find
and replace each occurence of ="/ with ="http://www.example.com/.

Any other suggestions?

--
DTM :<|
www.danfingerman.com
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump