Chaim
Chaim

Reputation: 2139

Using anchors on a page with <base> set

If I set my base url like so:

<base href='http://example.com' />

And then put a link to an anchor on the page http://example.com/test.php:

<a href='#top'></a>

How do I make sure the anchor stays on the same page and goes to the link http://example.com/test.php#top as opposed to going to http://example.com/#top because it uses the base url?

Essentially, is there any way to specify that this particular link must be relative and not use the base?

Upvotes: 3

Views: 270

Answers (1)

Jose Vega
Jose Vega

Reputation: 10258

You could either do:

<base href='http://example.com' />
<a href='test.php#top'></a>

or

<base href='http://example.com/test.php' />
<a href='#top'></a>

I don't think there is any magic way that the client is going to know what file to use as part of the base if you don't define it.

Upvotes: 2

Related Questions