Jump to content

[SOLVED] Base Ref > anchor


jaymc

Recommended Posts

I used base ref in my html documents, however, this renders anchor links useless

 

e.g. <a href="#top">Top</a>

 

That will just go to the document root and add #top after the URL

 

Searched around on google and seems to be a known problem but cant seem to find anyone with a solution where as I can use both successfully

 

Any ideas?

Link to comment
Share on other sites

The base element, which is contained in the head of the document, provides a method for defining the base URL for all links and form submissions on a page. It also provides a common target (in the form of a named window) for all of these links or form submissions.

 

This element isn’t used very often these days, as making links is usually a simple case of creating links to documents relative to the web server root, like so:

 

I've published my <a href="/travel-writing/">holiday diaries</a>,

    including the <a href="/travel-writing/prague/2006/day2.html">crazy

    bone church at Kutna Hora</a>

 

 

why would you use those?

but anyways im thinking you could just do from base

 

 

 

Base being included in this== http://www.imagesbytroy.com

<a href="/pricing.php#general">Top</a>

 

something like that

 

Link to comment
Share on other sites

why would you use those?

 

Base href can be very useful when working in the confines of a larger scale system (such as a CMS) when different environments are needed. For instance, in a preview or dev environment, being able to set the base href to a location where all scratch versions of pages (and everything else, for that matter) reside can be extremely useful. Additionally, if you set all the links in an application to the web root by using absolute paths, you run into the problem of that application always having to be installed at the web root. Setting the base href can be very useful to overcome this challenge by allowing the base href to be a configuration variable so that all links within a given code base will reference the same base.

 

So, as you can see, there are definitely viable reasons to use the tag, although it is definitely not always the best solution for path fixes, especially when using in-page anchors.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.