Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

rewriteHashlinks


Reply


2 Posts   1594 Views

Avatar
Nicolaas

Forum Moderator, 213 Posts

5 June 2007 at 11:14am

Hi Folk

rewriteHashlinks (part of the sapphire/core/SSviewer.php file), is really useful (it adds the current URL any links starting with # (internal links e.g. <a href="#top">go to the top</a>) , but unfortunately, it does not apply to the content (the data that is entered in the CMS by the admin) of the page itself. How would you recommend I go about implementing it in the content itself?

Any hints much appreciated.

Nicolaas

Avatar
Nicolaas

Forum Moderator, 213 Posts

5 June 2007 at 11:46am

Edited: 05/06/2007 11:47am

Hi

This is what I have written in JS to fix it....
var currentUrl = location.href;
var As = document.links;
for(i = 0; i < As.length; i++) {
var A = As;
if(A.href) {
var afterHash = A.href.split("#")[1]
if(afterHash) {
if(afterHash.length > 0) {
A.href = currentUrl + "#" + afterHash;
}
}
}
}