Developer forum

Forum » Templates » anchor refs are added absolute path

anchor refs are added absolute path


Reply
Hi,

When creating an anchor in an a tag like this href="#gotohere" in an template it seems like the absolute path is added ahead of the anchor - so the a tag presented in the browsers is like this: href="www.mycoolwebsite.com/default.aspx#gotohere"...

Is there some kind of checkbox so I can get rid of this pretty anoying "feature"?

/Regin Madsen

Replies

 
Nicolai Høeg Pedersen
Reply
Hi Regin

Can you provide an example url - think it has to do with base href when using custom urls.
 
Reply
Hi,

Sure, you can have a look at this url:
http://nitodan.net.dynamicweb.dk/Danmark---test.aspx?Purge=True

I have seen this on 3 different sites however, where at least two are using different url "types"

One using and one using

/Regin
 
Nicolai Høeg Pedersen
Reply
I've just tested it - it does not get the absolute path in source code...

But when pointing at it the browser shows the entire URI - because of the base href I gues... But it works like a charm here.
 
Reply
Im sorry, I was not precisely enough.

Its not absolute paths I mean, actually its relative paths.

But the problem is:
<a href="/Danmark---test.aspx#gotothis">a test</a>
The above is what is in the source on the pageview...

This is what is entered in the template:
<a href="#gotothis">a test</a>

Seems like DW is adding the pagename to the href, which is not what is wanted...

 
Nicolai Høeg Pedersen
Reply
This is due to the base href of the SEO friendly urls.

if a base href to www.domain.dk exists and a anchor of name "#some" on a page called /Welcome.aspx it will do like www.domain.dk/#some because of the base href. That would not work then.

What is the problem with the /pagename.aspx#anchorname approach?
 
Reply
OK...why? 

If I want a pagename to be included in my href I can do it myself with a tag.

My problem is that I have a number of sites using vairous JS scripts (eg. fancybox) where an anchor is used as the href to open a popup.

Furthermore if I simply want to go to an anchor on the page the page needs to be refreshed when you add this in front.

So again - why? Why do Dynamicweb CMS happens to know better than myself what URI I want ;-) ?

/Regin Madsen
 
Nicolai Høeg Pedersen
Reply

Giving I'm on this URL: http://engage.dynamicweb-cms.com/Something/else.aspx

Consider this code:

<html>
<head>
<base href="http://engage.dynamicweb-cms.com/" />
</head>

<a href="#someanchor">Go</a>


<a name="someanchor"></a>
Read all about it...
</html>


Clicking the #someanchor(Go) link would send you to http://engage.dynamicweb-cms.com/#someanchor - the frontpage which is incorrect.


That is why the relative url is added. To support what anchors are created to be.


I'll be happy to give you a check box to remove it - it will break normal usage of anchors when running some sorts of SEO urls though.
 

BR Nicolai
 

 
Reply
I do not agree

First of all I still think youre missing the point. DW should not add ANYTHING to my urls unless I tell it to. Again why do it? If I want the "address" to be part of my URL Ill add it myself using one of the tags giving me the current url.

Secondly I dont think W3C agree with you that "its the way its supposed to be".

Taken from W3C

HTML Links - The name Attribute

The name attribute specifies the name of an anchor.

The name attribute is used to create a bookmark inside an HTML document.

Bookmarks are not displayed in any special way. They are invisible to the reader.

Example

A named anchor inside an HTML document:

<a name="tips">Useful Tips Section</a>

Create a link to the "Useful Tips Section" inside the same document:

<a href="#tips">Visit the Useful Tips Section</a>

Or, create a link to the "Useful Tips Section" from another page:

<a href="http://www.w3schools.com/html_links.htm#tips">
Visit the Useful Tips Section</a>

The link is here... http://www.w3schools.com/HTML/html_links.asp

So URLS should only be added to anchors when going to an external url.

To be honest I really really cant see why you have added this feature, and most of all It seems like another "clippy" (from MS Word) thing you have thrown in.

But yes, if you do want to continuesly have this new feature which is added on a wrong basis, then please ad another checkbox to the "checkbox CMS"
 
Nicolai Høeg Pedersen
Reply
It has been there since SEO friendly URLs where introduced and removing it will break every use of anchors to navigate within a page on SEO url enabled sites - which is quite a lot.

That is why I'll give you a checkbox. So you can do fancy stuff and the editor can't do anchors.

W3C agrees with me...
- If you use the anchor with a base href tag, you also need to specify the relative path. Otherwise it FAILS. Taking a look at w3c:
W3C document on links: http://www.w3.org/TR/html401/struct/links.html
RFC describing relative link calculation: http://www.ietf.org/rfc/rfc1808.txt
So it is NOT wrong. It might be f..... anoying when you try to do fancy stuff, but it surdenly is w3c compliant.

- Fancybox as you tell it uses the name attribute to hold a URL - not exactly w3c compliant.

So it is not there to pis you or others off. It is there to make anchors work like they should.

Other things:
If the link does not start with # it does not get parsed - so you can do like:
<a href="whatever"> or <a href="%whatever">  and it will not get parsed.

But - discussing does not solve your problem. I'll have the checkbox added to the checkbox CMS right away so you'll have it with a service release pretty darn soon.

Anyways - thanks for the input. Hope you do not get the impression we do not care - because we do. There are places where DW can improve - so just keep it coming.

BR and have a nice weekend, Nicolai
 
Reply
Ahh yes, the base href, didnt take taht into account...

Iwe found a solution for my problem, So if you want to keep low on the checkboxes thats fine by me.

 
Reply
Hi,

Could you please provide the solution. I have the same problem trying to implement inline content with "prettyPhoto". 

I also need the <a href="#inlinecontent">Link</a> to stay that way.

After DW parses it, its changed to <a href="/Default.aspx?ID=25&#inlinecontent">Link</a>


Thanks in advance.

Regards / Aki

 

You must be logged in to post in the forum