• How to combine a BASE tag and internal links

    From R.Wieser@address@is.invalid to alt.html on Tue Jun 2 19:27:29 2026
    From Newsgroup: alt.html

    Hello all,

    I've got an HTML page with some internal links is the form of

    <a href="#no1">

    I'm also using (or trying to use) the BASE tag, so that all relative
    external links will actually resolve to another webpage.


    The problem is that the above "#no1" internal link *also* tries to resolve
    to an external webpage - where want to keep it in the current one.

    Is there a way to do that ? (other than making all external links absolute
    I mean :-) )

    Regards,
    Rudy Wieser


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From JJ@jj4public@gmail.com to alt.html on Wed Jun 3 17:33:45 2026
    From Newsgroup: alt.html

    On Tue, 2 Jun 2026 19:27:29 +0200, R.Wieser wrote:
    Hello all,

    I've got an HTML page with some internal links is the form of

    <a href="#no1">

    I'm also using (or trying to use) the BASE tag, so that all relative external links will actually resolve to another webpage.

    The problem is that the above "#no1" internal link *also* tries to resolve to an external webpage - where want to keep it in the current one.

    Is there a way to do that ? (other than making all external links absolute I mean :-) )

    Regards,
    Rudy Wieser

    With pure HTML? No.

    <base> defines & overrides the base URL for all relative URL references in
    the current page.

    The default base URL is the current page's URL minus anchor/hash.

    Mere `#here` URL is a relative URL. i.e. relative to the current page.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From JJ@jj4public@gmail.com to alt.html on Wed Jun 3 17:39:50 2026
    From Newsgroup: alt.html

    On Wed, 3 Jun 2026 17:33:45 +0700, JJ wrote:

    On Tue, 2 Jun 2026 19:27:29 +0200, R.Wieser wrote:
    Hello all,

    I've got an HTML page with some internal links is the form of

    <a href="#no1">

    I'm also using (or trying to use) the BASE tag, so that all relative
    external links will actually resolve to another webpage.

    The problem is that the above "#no1" internal link *also* tries to resolve >> to an external webpage - where want to keep it in the current one.

    Is there a way to do that ? (other than making all external links absolute
    I mean :-) )

    Regards,
    Rudy Wieser

    With pure HTML? No.

    <base> defines & overrides the base URL for all relative URL references in the current page.

    The default base URL is the current page's URL minus anchor/hash.

    Mere `#here` URL is a relative URL. i.e. relative to the current page.

    So in your case, if that section link is in `main.html`, then the `href`
    must specifically point to `main.html` plus the hash. If base points to different origin, then the `href` must be an absolute URL. Or `//host/path` relative URL, if the protocol of both origins are the same.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to alt.html on Wed Jun 3 13:59:59 2026
    From Newsgroup: alt.html

    JJ,

    The problem is that the above "#no1" internal link *also* tries to
    resolve to an external webpage - where want to keep it in the
    current one.

    Is there a way to do that ? (other than making all external links
    absolute I mean :-) )

    With pure HTML? No.

    <base> defines & overrides the base URL for all relative URL references
    in the current page.

    I was already afraid of that.

    Though its a bit odd to me that a link starting with "#" (read: no
    relative path preceeding it) isn't recognised as being internal.

    Oh well.

    Regards,
    Rudy Wieser


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From JJ@jj4public@gmail.com to alt.html on Thu Jun 4 08:14:16 2026
    From Newsgroup: alt.html

    On Wed, 3 Jun 2026 13:59:59 +0200, R.Wieser wrote:

    JJ,

    The problem is that the above "#no1" internal link *also* tries to
    resolve to an external webpage - where want to keep it in the
    current one.

    Is there a way to do that ? (other than making all external links
    absolute I mean :-) )

    With pure HTML? No.

    <base> defines & overrides the base URL for all relative URL references
    in the current page.

    I was already afraid of that.

    Though its a bit odd to me that a link starting with "#" (read: no
    relative path preceeding it) isn't recognised as being internal.

    Oh well.

    Regards,
    Rudy Wieser

    Hash is part of URL components which are:
    protocol, host name/IP, port, path, variables, hash.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to alt.html on Thu Jun 4 08:26:21 2026
    From Newsgroup: alt.html

    JJ,

    Though its a bit odd to me that a link starting with "#" (read: no
    relative path preceeding it) isn't recognised as being internal.

    Hash is part of URL components which are:
    protocol, host name/IP, port, path, variables, hash.

    I know.

    Did you know that FF doesn't send the hash part when you click a link that
    has one ?

    Regards,
    Rudy Wieser


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to alt.html on Thu Jun 4 09:06:47 2026
    From Newsgroup: alt.html

    JJ,

    Hash is part of URL components which are:
    protocol, host name/IP, port, path, variables, hash.

    To be more precise :

    protocol, [username], [password], host name/IP, [port], [path], [variables], [hash]

    with the bracketed parts optional (the protocol may be omitted *in a link* when the string starts with a double slash).

    In that regard of the above a link with an href starting with a hash is invalid.

    ... yet, it works perfectly. :-)

    Regards,
    Rudy Wieser


    --- Synchronet 3.22a-Linux NewsLink 1.2