Anchor links don't work on pages with query strings - hyperlink

I've become dumbfounded by this. This might be something that I've just assumed worked all along, but in fact has never worked.
I've got an anchor link on a page [Activities] and later on the page I have the anchor <a name="activities"></a>. This is the URL of the page: https://iassid.org/index.php?option=com_content&id=216
For some reason, the anchor link on the page brings the user back to https://iassid.org/index.php#activities
Has removing the query string always been normal behavior? The href in the anchor tag doesn't include anything but the hash, why would it even assume to go off the page? Why does it go back to the original URL without the query string? Is there any way to get this to work without putting the entire URL including the query string in the URL as well? I'm trying to make this easy for someone who isn't very familiar with HTML, so using onclick events and other options aren't desired.
Maybe I've just been crazy to assume this would work all along! Thanks for any insights.

Related

How to use native anchor links with angularjs

I'm using angularjs on a rather large flat documentation page. The page has some navigation thats designed to use traditional url hash links. The urls look like so:
/documentation/flat#26166276-basic-events
These urls get rewritten once the navigation occurs and i've hit the next page. angular initializes to something like:
/documentation/flat#/26166276-basic-events
This breaks the navigation. It seems to work if I am already on the /documentation/flat path and hit one of the hash urls. It gets rewritten but the browser still focus's on the correct section of the page.
However if the the hash url is triggered from a different path the browser will not focus on the correct DOM element as the angularjs rewrite happens.
Edit: this is what the markup for a link looks like
Basic Events
<h1 class="chap-header" id="26166276-basic-events">2.1.0 Basic Events</h1>
This topic was further discussed here:
How to handle anchor hash linking in AngularJS
I used a variation from that thread
if $location.$$url[0]== '#'
$location.hash($location.$$url.replace('#', ''))
$anchorScroll()
that basically lets me prefix any anchor links with an additional # and angularjs treats them as traditional anchor
There is a very silly solution: put a / at the start of the anchor id!
<a id='/my-id' />

Change the url of a pagination in grails

Can anyone help me how to change the url displayed in the address bar in grails.
Here I have a data table. Once i click on the pagination list displayed at the bottom, lets say 2, then the url changes to
http://localhost:8080/test/account/list?searchText=%25&paginationNumber=10&advancedSearchText=&searchCriteria=&searchOperator=&offset=10&max=10
from
http://localhost:8080/test/account/list
Now I need the same url
http://localhost:8080/test/account/list
even i navigate to different pages.
Whether it is possible to override the url in grails.
It looks like your original page was the result of a form POST, with these additional parameters as fields on the form. When you use <g:paginate> it generates a normal <a> link for each button, which means a GET request, so the params go into the URL.
You might be able to get it to do what you want with a bit of JavaScript, wrapping a POST form around the paginate buttons with hidden fields for the additional data, and attach an event handler to the pagination links to trigger a submit of the form.
Alternatively, store the extra parameters server side in the session instead of passing them back and forth, and accept the offset and max in the URL.

A shorthand for multiple links?

I have a fairly long list of quick links (approx. 20) that I'm going to embed on my main page. Instead of adding the full url of each link to the each anchor, is there a way to add maybe the end of each link.
For instance, if the link to the url is
http://support.proboards.com/index.cgi?display&thread=423890
as you can see, my forum is a proboards forum if that helps anything here.
the location of each url is local,
Instead of adding the complete url, is there a way to use something like
<a href = "&thread=423890">
or maybe
<a href = "this.thread=423890"> ?
Not in pure HTML, the best you'll get is <a href="index.cgi?display&thread=423890">, which is what you should already be using. Of course I'm assuming support.proboards.com is your site here.
You could use JavaScript and call a function like openThread(423890) if you really wanted, but a)I wonder what you really gain from it, b)this won't work for people with JavaScript turned off (a la NoScript), and c)I wonder if Google would properly see all the links.
Presumably, these pages are all being generated by server-side script anyway, so you should only really be coding index.cgi?display&thread= once anyway...
If you're hard-set on doing something shorter, I'd suggest using URL rewriting. You can have a URL like .../display/thread/423890 and then use something shorter if you're already from a /display/thread/ page. But this requires the link to go to a page you have control over.

What is the meaning of # in URL and how can I use that?

I often found some URL which looks like the following:
www.something.com/some_page/#someword
After writing this page some_page will be open and then scroll will be set so that I can see that "someword" at beginning of my screen.
I don't know what the meaning of "#" is. As soon as I make #someotherword with any URL it works sometimes and sometimes it doesn't.
I am not getting what # is in the URL. Is it any functionality of any language or URL or something else?
It might be possible that you consider my question newbish, but I am not into web-designing technologies, I am simply curious about it.
I am not the owner of some website, but when I am concerned with some particular portion of some web page then how can I give the URL with # and give that URL to another?
I am concerned with the answer portion on my profile, and then I will prepare the URL just below and will give it to somebody.
https://stackoverflow.com/users/775964/mr-32#answers
This works, but some time it doesn't.
https://stackoverflow.com/users/775964/mr-32#tags
That doesn't work.
I am just a user and I don't want to know in which language the website is build.
Originally it was used as an anchor to jump to an element with the same name/id.
However, nowadays it's usually used with AJAX-based pages since changing the hash can be detected using JavaScript and allows you to use the back/forward button without actually triggering a full page reload.
This is known as the "fragment identifier" and is typically used to identify a portion of an HTML document that sits within a fully qualified URL:
Fragment Identifier Wiki Page
It is an anchor for links within a page - also known as "anchor tag"
http://www.w3.org/TR/html4/struct/links.html#h-12.2.3
It specifies an "Anchor", or a position on the page, and allows you to "jump" or "scroll" to that position on the page.
Apart from specifying an anchor in a page where you want to jump to, # is also used in jQuery hash or fragment navigation.
Anchor with an id
Dead link Hash or fragment navigation
Tips for better fragment navigation
Yes, it is mainly to anchor your keywords, in particular the location of your page, so whenever URL loads the page with particular anchor name, then it will be pointed to that particular location.
For example, www.something.com/some_page/#computer
if it is very lengthy page and you want to show exactly computer then you can anchor.
<p> adfadsf </p>
<p> adfadsf </p>
<p> adfadsf </p>
<a name="computer"></a><p> Computer topics </p>
<p> adfadsf </p>
Now the page will scroll and bring computer-related topics to the top.

not having to encode url

Say I have this url "/my#stuff"
I am using asp.net mvc and when I try to goto this page it takes me to just "/my". The "#stuff" part has been removed.
Now I can get it to work fine if I encode the URL like so "/my%23stuff" since %23 decodes to #
However, is there a way I can get this to work without having to encode the url?
I'd like it if typing in "/my#stuff" as the URL worked just the same as "my%23stuff"
I don't think there is a way to do what you are saying. The hash is used in a URL for anchor tags.
You are pointing at a page /my and navigating to anchor tag "stuff" on that page. If anchor tag "stuff" does not exist it will just navigate to page /my.

Resources