Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 964
Chaim Avatar asked Dec 22 '25 14:12

Chaim


1 Answers

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.

like image 123
Jose Vega Avatar answered Dec 24 '25 05:12

Jose Vega



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!