A shorthand for multiple links? - shorthand

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.

Related

<h1> <h2> seo link tag

i know <h2>Hamburger</h2> are good, but how about this:
<div><h2>Food ยป Hamburger</h2></div>
or thats are ok for google seo?
The tag with an anchor link inside it will work same as a normal tag for Google SEO. Both the methods are Ok, but the problem that can occur is your readers may go away because you added a hyperlink in the Heading text of your webpage. So, it is not a good practice to use hyperlinks in tags or any tag.

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

Why is my external link rendered as internal link?

I have a form that let people enter various links on my website like: http, https and ftp. When someone enters "http:stackoverflow.com", "https:stackoverflow.com" and "ftp:stackoverflow.com" and renders these in a view like this:
<ul>
#foreach (var link in Model.Keyword.References)
{
<li>
#link.Link
</li>
}
</ul>
I get the following output:
http:stackoverflow.com
https:stackoverflow.com
ftp:stackoverflow.com
This looks fine but when I hover "http:stackoverflow.com" the real link is: "localhost:1973/stackoverflow.com".
When I hover the https and ftp links I get the correct output:
https://stackoverflow.com
ftp://stackoverflow.com
I found out that the http links requires two "forward slashes" when I submit them via a form. So instead of "http:" you get "http://". I would like to know why https and ftp links do not need these extra slashes. I would also like to know a good solution for this because I don't think I should force an user to use these extra slashes.
The slashes in the URL are always required. It could be that your browser does some correction to the invalid url. Try to put https:stackoverflow.com in the addressbar of your browser and it will try to correct it in most browsers.
As for a good solution, I think you should only accept the domain without http://. You can put some small text underneath the input that shows "Example: 'www.somedomain.com'", so that the user knows the protocol in the front is not needed.
You can then use JQUERY/REGEX to validate and trim off any protocol stuff someone might add mistakingly.

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.

Is there a way to change the browser's address bar without refreshing the page?

I'm developing a web app. In it I have a section called categories that every time a user clicks one of the categories an update panel loads the appropriate content.
After the user clicked the category I want to change the browser's address bar url from
www.mysite.com/products
to something like
www.mysite.com/products/{selectedCat}
without refreshing the page.
Is there some kind of JavaScript API I can use to achieve this?
With HTML5 you can modify the url without reloading:
If you want to make a new post in the browser's history (i.e. back button will work)
window.history.pushState('Object', 'Title', '/new-url');
If you just want to change the url without being able to go back
window.history.replaceState('Object', 'Title', '/another-new-url');
The object can be used for ajax navigation:
window.history.pushState({ id: 35 }, 'Viewing item #35', '/item/35');
window.onpopstate = function (e) {
var id = e.state.id;
load_item(id);
};
Read more here: http://www.w3.org/TR/html5-author/history.html
A fallback sollution: https://github.com/browserstate/history.js
To add to what the guys have already said edit the window.location.hash property to match the URL you want in your onclick function.
window.location.hash = 'category-name'; // address bar would become http://example.com/#category-name
I believe directly manipulating the address bar to a completely different url without moving to that url isn't allowed for security reasons, if you are happy with it being
www.mysite.com/products/#{selectedCat}
i.e. an anchor style link within the same page then look into the various history/"back button" scripts that are now present in most javascript libraries.
The mention of update panel leads me to guess you are using asp.net, in that case the asp.net ajax history control is a good place to start
I don't think this is possible (at least changing to a totally different address), as it would be an unintuitive misuse of the address bar, and could promote phishing attacks.
This cannot be done the way you're saying it. The method suggested by somej.net is the closest you can get. It's actually very common practice in the AJAX age. Even Gmail uses this.
"window.location.hash"
as suggested by sanchothefat should be the one and only way of doing it. Because all the places that I have seen this feature, it's all the time after the # in URL.

Resources