hashtags in urls stop links from working. Topic is solved

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Locked
martin691
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Thu Aug 27, 2009 4:57 pm

hashtags in urls stop links from working.

Post by martin691 » Tue Sep 17, 2019 5:56 pm

Hi,

I am trying to use an <a href> link with a hashtag in it. As soon as I put a hashtag in, the link no longer works.

Code: Select all

<p>
<a href="https://www.signupdate.co.uk/videos/#prettyPhoto/19/">test link with a hashtag in the link which doesn't do anything at all</a>
</p>
<p>
<a href="https://www.signupdate.co.uk/videos/prettyPhoto/19/">test link <strong>without</strong> a hashtag in the link which does go to another website</a>
</p>
If I do this in a simple html file then both links work: https://www.signupdate.co.uk/test-hashtags.html

But if I embed the same code in a joomla article, then the first link doesn't do anything, despite the fact that when you hover over it, you can see that it appears to be a link - as you can see here: https://www.signupdate.co.uk/Sign-News/test

Any idea why this link doesn't work in Joomla?

Thanks in advance.

I'll also add the link here, and I can see this works: https://www.signupdate.co.uk/videos/#prettyPhoto/19/

So it appears to be an issue with my Joomla website, but not with this forum which is also hosted on Joomla I think.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 28444
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: hashtags in urls stop links from working.

Post by Per Yngve Berg » Tue Sep 17, 2019 6:23 pm

You are aware of that # has a special meaning in links. #prettyPhoto will take you to an achor point "prettyPhoto" on the same page.

https://www.w3schools.com/html/html_links.asp

martin691
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Thu Aug 27, 2009 4:57 pm

Re: hashtags in urls stop links from working.

Post by martin691 » Tue Sep 17, 2019 6:58 pm

Yes that's what I want it to do, but the hashtags somehow disable the <a href> tag, but only on my Joomla site.

martin691
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Thu Aug 27, 2009 4:57 pm

Re: hashtags in urls stop links from working.

Post by martin691 » Tue Sep 17, 2019 8:44 pm

I have just tried the exact same code on another Joomla website in an article in the same way and that works.
I can't think what is different with the www.signupdate.co.uk Joomla website.

martin691
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Thu Aug 27, 2009 4:57 pm

Re: hashtags in urls stop links from working.

Post by martin691 » Tue Sep 17, 2019 8:52 pm

I have also switched to another template and that fixes this problem.

So it appears to be something in this template:
Gk News 2 by GavickPro

Only problem is that I need to use this template, so not really an option to change it.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 28444
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: hashtags in urls stop links from working.

Post by Per Yngve Berg » Wed Sep 18, 2019 4:53 am

Probably a js script that moves to another location.

waarnemer
Joomla! Hero
Joomla! Hero
Posts: 2954
Joined: Sun May 04, 2008 12:37 pm

Re: hashtags in urls stop links from working.

Post by waarnemer » Wed Sep 18, 2019 6:00 am

a url that ends with domain.com/page#anchor will move to that page and scroll down to that anchor.
but your url is like /page#anchor

the /a_number_within_forward_slashes/ isn't correct as the slashes imply there is a "subdirectory"

martin691
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Thu Aug 27, 2009 4:57 pm

Re: hashtags in urls stop links from working.

Post by martin691 » Wed Sep 18, 2019 8:45 am

The actual working link is to a customers website and direct to a video, and it does work, so I don't want to change the url, otherwise I have to get my customer to change his website, which may involve him getting his developer involved:
https://www.impactsignsolutions.co.uk/v ... yPhoto/19/

I also thought it was a wierd url as it's not how I'd expect a hashtag to be used too.

So still have the problem as to why the hashtag disbles the link in my Joomla website here:
https://www.signupdate.co.uk/Sign-News/test

waarnemer
Joomla! Hero
Joomla! Hero
Posts: 2954
Joined: Sun May 04, 2008 12:37 pm

Re: hashtags in urls stop links from working.

Post by waarnemer » Wed Sep 18, 2019 9:19 am

as it is no valid url. right click your link with hashtag and open in new tab. You will see it opens a page with title "page not found".

So similar to the one that has no hash... take away the /19/ and it probably will open a page not found...

I dynamically did remove the /19/ (using the console F12 inspect elements) if I take out the /19/ it does jump to the other page (not found)

martin691
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Thu Aug 27, 2009 4:57 pm

Re: hashtags in urls stop links from working.

Post by martin691 » Wed Sep 18, 2019 10:21 am

My problem is that the link isn't clickable as soon as there is a hashtag in the link, the link stops working.
The example I gave doesn't go to a valid page, as I was just interested in why the hashtag stops it from working.

I have amended the article with the problem in it, so that it does have a valid page:
https://www.signupdate.co.uk/Sign-News/test

Does anyone know why the first link doesn't do anything? I can see that changing the template does fix the problem, so it does appear template related.

The url in the link is unusual I know, but these open up different videos as you can see below:
https://www.impactsignsolutions.co.uk/v ... yPhoto/19/
https://www.impactsignsolutions.co.uk/v ... yPhoto/20/
https://www.impactsignsolutions.co.uk/v ... yPhoto/21/

waarnemer
Joomla! Hero
Joomla! Hero
Posts: 2954
Joined: Sun May 04, 2008 12:37 pm

Re: hashtags in urls stop links from working.

Post by waarnemer » Wed Sep 18, 2019 10:49 am

You are trying to catch something with javascript..

When I check the source, there is no id having "prettyPhoto/19/" there is nothing on a page to scroll to
Since the #with a id name is tied to an anchor on a page (at least that is how it is supposed to) this will give issues... you are trying to
I now only receive the modal with the video when linked from this thread.. when I am at 19 and type 20 or 21 manually, nothing happens.... that is of course expected behaviour since there is no id with that name. The page doesn't need to reload on a samepage# url.

If you are using javascript to open modals with videos, you may want to do that using the appropriate markup. In this case that would be "?prettyPhoto=19"
You also do need to catch the event.

Back to why it isn't working on your page... you have a jQuery issue of your own. Check F12 tab console.
Click on the link and you will see there is an error.... you are doing something to catch urls on click...

Are you doing something with outgoing links? track them in analytics? turn it off and check again....

martin691
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Thu Aug 27, 2009 4:57 pm

Re: hashtags in urls stop links from working.

Post by martin691 » Thu Sep 19, 2019 3:28 pm

I just posted on the Gavick Pro Template providers website and their response was:
Template has a smooth-scroll function implemented. If hash is recognised it looks for a layer with an ID of this hashtag, You can use this functionality or edit template's /js/gk.scripts.js file and remove function related to smoothScroll.
I just disabled the Smooth Scroll, and this has fixed it.

waarnemer
Joomla! Hero
Joomla! Hero
Posts: 2954
Joined: Sun May 04, 2008 12:37 pm

Re: hashtags in urls stop links from working.

Post by waarnemer » Thu Sep 19, 2019 5:33 pm

so it wás looking for an anchor tag in your site the soft way... and there wasn't any... oh well...

anyway.. still, if you want to load content dynamically use the proper syntax for url query params.. like

?prettyPhoto=19

just to avoid any other [removed] in the future....

george_vn
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Jun 02, 2020 6:29 am

Re: hashtags in urls stop links from working.

Post by george_vn » Tue Jun 02, 2020 6:36 am

I was having the same problem on http://top5hosting.uk (It uses the Gavick cloudhost template). The solution in this thread fixed it. I had to go to /js/gk.scripts.js and comment this line of code:

Code: Select all

/* if(jQuery(document.body).attr('data-smoothscroll') == '1') {
		// smooth anchor scrolling
		jQuery('a[href*="#"]').on('click', function (e) {
		    e.preventDefault();
		    if(this.hash !== '') {
		        if(this.hash !== '' && this.href.replace(this.hash, '') == window.location.href.replace(window.location.hash, '')) {
		            var target = jQuery(this.hash);
		            if(target.length && this.hash !== '#') {
		                jQuery('html, body').stop().animate({
		                    'scrollTop': target.offset().top
		                }, 1000, 'swing', function () {
		                    if(this.hash !== '#') {
		                        window.location.hash = target.selector;
		                    }
		                });
		            }
		        }
		    }
		});
	} */
This fixed the issue with the # hashtags in the external urls and now it works as it is supposed to.

I think all Gavick templates that have this smothscroll function will have the issue.

shaun441
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Jun 04, 2020 6:57 pm

Re: hashtags in urls stop links from working.

Post by shaun441 » Thu Jun 04, 2020 7:08 pm

Im having the same issue as well. Can it be caused by the particular template or server configuration issue?

george_vn
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Jun 02, 2020 6:29 am

Re: hashtags in urls stop links from working.

Post by george_vn » Sun Jun 07, 2020 10:41 am

shaun441 wrote:
Thu Jun 04, 2020 7:08 pm
Im having the same issue as well. Can it be caused by the particular template or server configuration issue?
It seems it is on most gavick templates and it is caused by this smooth scroll javascript. Of course, it could be something on the server side, but I would check the javascript libraries first. A lot of them use the # for something on the page. Check the console on your browser dev tools, it can give you hints of what and where the problem could be.

alainG+
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Thu Jul 24, 2014 10:04 pm

Re: hashtags in urls stop links from working.

Post by alainG+ » Mon Jun 08, 2020 7:14 pm

Hello,
Just an idea, I have the same problem and the reason was that the url on the site was cached under a div zone and of course a transparent one !
Alain.


Locked

Return to “General Questions/New to Joomla! 3.x”