Developer forum

Forum » Rapido » Linking to # makes the page reload

Linking to # makes the page reload

Mike Nicolai Bjerregaard
Mike Nicolai Bjerregaard
Reply

Hi,

I'm not sure its a rapido related "issue" or me doing it wrong.

I'm trying to make a link on my page that goes to a #content - And it seems to work on other custom solutions we have build.

But when i do this in Rapido, the link goes to the # point on the same page, which is good and what its supposed to do.

But meanwhile it seems to refresh the page (it doesn't do this on our other solutions), which i'm not really looking for. Since it resets my "tab" position and goes back to the starting point again.

My link: <a href="/Default.aspx?ID=@(Model.ID)#content">

i also tried to only do "#content" as its normally done, but then it sends me back to the frontpage and does nothing.

 

Best regards

Mike


Replies

 
Nicolai Pedersen
Reply

Hi Mike

By default dynamicweb inserts base href tag in the header - and that is causing this. You can disalbe that in the backend in http settings:

https://doc.dynamicweb.com/documentation-9/platform/advanced-settings/web-and-http#3521

Usually you can just disable this - but you need to check that you do not have links that requires that set.

 
Mike Nicolai Bjerregaard
Mike Nicolai Bjerregaard
Reply

Hi Nicolai,

Thanks for the response.

I will try look into that base href tag.

It just seems odd to me, that its not disabled on our soluitions where its working. But not on my rapido solution.

 
(from the solution, where it works fine)

Best regards

Mike

 
Nicolai Pedersen
Reply

Hi Mike

When you click an achor link, the browser is in charge of how it works, not us.

Check the source code of the solution and see if there is a base tag or not. You can also remove it in the inspector in developer tools (if you knwo that one) and see if it works.

You can implement the template so it will not output base href eventhough it is not disabled, so that would be my guess.

BR Nicolai

 
Mike Nicolai Bjerregaard
Mike Nicolai Bjerregaard
Reply

Hi Nicolai

I have been testing a little together with my colleague and It doesn't seem to change anyting.

The thing we noticed is when disabling JS from the page, the link works just fine and doesn't reload anything. Guess thats also it works fine on custom solution.

So my thought is that there must be something in the master.js which does this part. But i'm testing it a little bit more, unless you know anything that could cause it in there.

Example here: http://dynamicwebdemo.dwsales.dynamicweb-cms.com/about - if you click the "Online" link in the top text, it reloads, even when disabling base href. But works fine when i disable javascript for the page.

 

Best regards

Mike

 
Mike Nicolai Bjerregaard
Mike Nicolai Bjerregaard
Reply

Hi NIcolai,

The problem is, we are trying to "Adding a link at the top of each page that goes directly to the main content area" (https://www.w3.org/WAI/WCAG21/Techniques/general/G1).

Which at the moment isn't working really great, since everytime we click that link. It refreshes the page and will start over at the same navigation point agian (which then you can't really skip the navigation).

Is there any workaround this, so that we can add this link propperly and make it work, as it seems to only be a problem on our Rapido solutions, maybe adding a class to the link, so it won't be caught by the Rapido javascript?

 

Best regards

Mike

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Mike

You can remove this from master.js:

window.addEventListener('popstate', function (event) {
        location.reload();
    });

It might have side affects when in product catalog - it is used when users are using back and forward buttons in the browser to load the right ajax content.

BR Nicolai

Votes for this answer: 1
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Mikke,
Can you check in your solution, in GlobalSettings the value of "DsiableHrefNameParser"?

It should be set to true. 

Adrian

 
Mike Nicolai Bjerregaard
Mike Nicolai Bjerregaard
Reply

Hi Nicolai

Thanks! it worked! Exactly what we were looking for.

Fortunately we don't have any products on this site. But will keep it in mind, if we have the same issue on a website with products.

 

Have a nice weekend!

 

Best regards

Mike

 
Mike Nicolai Bjerregaard
Mike Nicolai Bjerregaard
Reply

Hi Adrian

It is set to True, but the problem is solved now. Thanks anyways!

 

Best regards

Mike

 

You must be logged in to post in the forum