Support forums : You can sense the bug

BASE element affects #anchor links

Not like "it smells funny when I click that". This is for bugs that don't show an error but something just doesn't seem right or ends up doing something you think is wrong. It doesn't show you an error but you know something ain't right.

Moderator: Dracones

BASE element affects #anchor links

Postby Laibcoms » Tue Aug 17, 2010 12:59 pm

I know this is an age-old topic re: BASE element but might as well make a post about it here. There are both advantages and disadvantages to the use of the BASE element, and there were both positive and negative arguments presented on the table in ages past (you know, the other forum/software). But I can not remember if the #anchor (ie id-anchor) link problem was presented on the table.

Here's the case:
BASE element contains the direct path to the "current" template. Let's put a value of: example.com/blog/qp_templates/nonzero/

The code:
Code: Select all
<a href="#idlink">test</a>


Because we have a BASE element declaration, the link results to this: example.com/blog/qp_templates/nonzero/#idlink
Without the BASE element (or if the element points to the blog/post itself), it will instead be: blog1.php#idlink or blog1.php/somepost#idlink

If we do this:
Code: Select all
<a href="/#idlink">test</a>


It tells the browser to prefix the blog/post URL itself - directly, not relatively.
So, /#idlink becomes example.com/blog/blog1.php#idlink --> which when clicked, it reloads the page. And depending on many factors, it may or may not jump to #idlink after reloading.

But if it is as it should be:
Code: Select all
<a href="#idlink">test</a>


Then it will jump to #idlink without any reloading. But then again, we have the BASE element as stated earlier.

It makes href="#idlink" impossible to use with the BASE element pointing elsewhere but the blog/post itself. I hope there's another way to achieve either: [1] the purpose behind the use of the BASE element; and/or [2] making href="#idlink" work as intended - to jump (and without reloading).

Thanks.
QuamPlures Template: Paninap Themes
Add me: Google+
Blogs: The Hæven of John; gameshogun
Laibcoms
Dracone
User avatar
 
Posts: 111
Joined: Thu Jan 14, 2010 5:29 am
Location: Philippines, Asean

Re: BASE element affects #anchor links

Postby EdB » Tue Aug 17, 2010 5:57 pm

Using it as a relative thing is pretty much required else each template that calls an image in a style sheet will have to somehow know what the domain.tld/path_if_any is. I guess that could be done...

Anyway I often thought QuickTags could and should have a button for "internal anchor". Linking to an anchor outside the current post is no problem - just use the full URL you want to go to. But internal anchoring is different cuz you don't know the post info when you're writing it. Plus all the crap about what kind of URL are we. So anyway I thought what if it put something like this in:
Code: Select all
[anchor]="#idlink">test[/anchor]
Then of course be an actual renderer instead of just a bunch of buttons. One could actually get really fancy-pants with it and make it render
Code: Select all
<!-- anchor:toc -->
into a table of contents based on internal anchors if one wanted to.

Actually never mind doing it to QuickTags: one could write a plugin that just looks for the basic anchor deal or doing an A with only a name and render that out. Then include the idea of a TOC.

Off topic I think they got rid of <a name="foo"></a> in html5. "Do something else instead" which if memory serves the something else is <div id="foo"></div>. Because in semantic markup a named anchor just isn't semantic enough. A div (obviously) carries so much more meaning :roll:


<a href="/#idlink">test</a> - that actually works in QP as-is? I mean, it might break if you have URLs with params but I dunno but anyway I never saw using a / before the # so how 'bout that.
EdB
Dracone
User avatar
 
Posts: 2072
Joined: Sun Nov 22, 2009 7:20 am
Location: Maricopa Arizona

Re: BASE element affects #anchor links

Postby Yabs » Tue Aug 17, 2010 6:37 pm

IIRC the <base> tag was implemented to help crippled browsers (read : IE ) work out where shit was relative to the file that called them ... *really* can't remember if that's IE6- or not. Either way, I killed <base> on my own blog ages ago and it still seems to work, and allows <a href="#get_a_better_browser"> .. mind you, my tacky.css doesn't include "../../rsc/css/any.css", so hardly "tested" ;)

Off topic <a id="foo">bar</a> works, or id on any element ;)

Off topic *really* need to add a "preview" button to the quick reply buttons, saves clicks and stuff


¥
I may have opened the door but you entered of your own free will

Image Techno Babble II
Image Tacky Pad 3
Yabs
Dracone
User avatar
 
Posts: 896
Joined: Sat Nov 21, 2009 9:59 am


Return to You can sense the bug

Who is online

Users browsing this forum: No registered users and 1 guest

cron