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
https://forums.phpfreaks.com/topic/129249-solved-base-ref-anchor/
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

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.