HTML Urls - how to append to the existing url - url

This is a stupidly easy question, however after searching for a long time I have yet to yield any results.
My question is as follows.
I have a webpage with the url http://domain.com/mypage/ladeda/
I have a link on this page.
Page 1
That link sends me to http://domain.com/1/
Page 1
That link takes me to http://domain.com/mypage/1/
How do i get my link to take me to http://domain.com/mypage/ladeda/1/
without having to extract all the aspects of the page url and put them within the href.
Many Thanks

<base href="/mypage/ladeda/" />
...
(goes to http://domain.com/mypage/ladeda/1/)
Via the <base> element.
But!
Page 1 should take you to http://domain.com/mypage/ladeda/1/ already provided that (a) you don't use a <base> element already and (b) the current resource is really http://domain.com/mypage/ladeda/ (with a trailing slash).

Page 1
If the current page isn't in the same directory (real or virtual) as the target page, you're going to have to specify a complete path. Either relative, or absolute. There's no way around it.

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' />

Anchor links don't work on pages with query strings

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.

A href URL with div ID wildcard

Is there a way to open a page and jump to a div ID when only part of the ID is known?
eg: http://wp-site.com/webpage.php#div-id-name-xxxx
where 'xxxx' is a set of numbers that are impossible to know until after the page has loaded.
I'm using a shortcode which generates a page element within a div where the beginning of the ID is standard (eg: tabs-bottom, contact-form, etc) followed by a unique number that is randomly generated each time the page loads.
I want to be able to link to the div on that page from another page, but with part of the ID being dynamic, I'm having trouble doing so. I thought passing a wildcard in the URL might be the way to go...
Any ideas?
ps: the pages are part of a Wordpress based site, if that helps.

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.

Can I use canonical URL on the same page it links to?

I want to ask about canonical URL. Lets assume this URL structure:
/category_A/page1
/category_B/page1
/category_C/page1
Simply put, there are multiple URLs that display the same content. But only /category_A/page1 is original(canonical) page. My question is if it have any impact(bad/good/neutral) considering SEO if I will have canonical URL pointing to /category_A/page1 placed in this same page /category_A/page1 ?
The reason for this is, that its much easier to just put canonical URL into head of every page than to trying find out in which page it is not needed (its the same page as canonical one)
just do it
you described the perfect use case for the canonical tag. the canonical tag is a kind of failsafe against wrong URLs (or URLs with unnecessary parameters). so it's good to have it even on the page with the URL the canonical points to.

Resources