![]() |
|
|
|||||||
![]() |
HTML - BASE attribute to ignore anchor links |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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. |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
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 |
|
|
|
#5 |
|
Posts: n/a
|
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 |
|
|
|
#6 |
|
Posts: n/a
|
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 |
|