Can I disable an address link in HTML? - html

I have the following:
Overview
Review
When I am on the overview page I want to make it so that clicking the overview address link does nothing. Something like disable for a button. Is this possible for an address link?

This should do it:
Overview
Of interest may also be nofollow:
Overview

The easiest way to disable a link is probably to remove the href value.
If you are rendering this from MVC, simply don't include the <a> tag.
It's a little unclear what is best for what you're trying to do.

Add 'return false' to prevent linking:
Overview

Just use a # sign in the href like so: Overview

You could do this with a layer of javascript on top of each page: your JS script would run and check all the links on the page -- if the link is the same as the page you are on then simply "hijack" the anchor by adding an onclick event which does nothing and doesn't bubble up the event.
This was you still pump out from your server side all the links -- and the script would be the same for all the pages, thus allowing it to be cached by the browser and only loaded once (assuming you place it in an external .js file).

You can try <a class="inactive" href="#">Overview</a> and give it some CSS to show it's a different type of link.

Related

What if I use #! instead of # in href of anchor tag <a>?

I have used #! in href of a tag in my website. It does not throws the user on top of the page if he/she clicks the link. But my question is, is it legal?
Click here
instead of
Click here
It seems your goal is to create something that the user can click on in order to trigger some JavaScript and you don't want side effects (like navigating to the top of the page).
is it legal?
It is not semantically correct. Links should be links.
It is a hack: You are linking to the element with id="!" and depending on the error recovery that happens when that element doesn't exist.
It is allowed under the rules of what constitutes valid HTML.
It is probably OK according to the various bits of accessibility legislation about the work which don't generally care if something works without JavaScript
The correct way to present a clickable control which exists only to bind JavaScript to is to use a button.
<button type="button">Click here</button>
You can apply CSS to make it look however you like though, so don't let "But it I want it to look like a link" stop you.
A more robust approach would be to use a server side fallback (i.e. a form submission or a link) and to cancel the default behaviour of the control by calling the preventDefault method of the event object.
Further reading:
Everyone has JavaScript, right?
Progressive Enhancement
Unobtrusive JavaScript
If your goal is to create something clickable in order to trigger some JavaScript function, then another way to achieve that is:
Execute JavaScript
It will execute JavaScript code when the user will click the link without refreshing or scrolling the page.
It is the best practice to link JavaScript.
Complete Example:
<!DOCTYPE html>
<html>
<body>
Execute JavaScript
</body>
</html>
For more details, see How to link to a JavaScript (HTML5 a href script)

Show/Hide feature using HTML only

I want to create an element where it performs a show/hide functionality of text when a user clicks on a button. I've found a helpful page through this link: http://www.meadinkent.co.uk/expand_sections.htm
The only issue I have is that it uses javascript. As I want to place this into Sharepoint, what Sharepoint does is remove the <script> everytime it's submitted, so javascript I'm assuming can't be used.
I want to know if there is a way to perform the same functionality as displayed in the page but with HTML only?
Thank you
You can add js by using Embed Code web part. Just go "Insert tab" and click "Embed Code". Then edit this and you will able to use js, css, html. So, you can use your helpful link.
Embed code webpart
You can use CSS to show/hide text. You can vist the following links, which may help you.
1) https://alexcican.com/post/hide-and-show-div/
2) How to show/hide div on click with stricly HTML/CSS

How to link a webpage to itself without first knowing its name?

To link a page to itself (e.g. http://example.com/folder/ThisPage.html), we can simply create a href as such:
ThisPage.html:
Link
This works, but has the disadvantage of needing to be updated when the file name changes. For example, if the file name changes to ThatPage.html, our href needs to change accordingly to Link.
I'm looking for an alternative without that disadvantage. I've tried:
Link
Doesn't work as Link does, because it appends a "blank query part" (question mark) to the URL.
Link
Doesn't work as Link does, on some browsers (e.g. Opera).
How do we link a page to itself, without having to update the relevant portion when the name of the page changes?
Note: JavaScript not allowed.
Just use Link. Nobody cares about the question mark appended to the URL. It does the requirement and that is what counts right?
It's very simple, just leave the href="" blank. So that's how:
Click me to refresh page
But this is not necessarily a good idea, because the cache may not be cleared, and whatever you need it for, if the page has changed in the meantime the change may not appear despite the reload. Probably a better idea is the javascript code location.reload(); to take. But there are enough explanations on other sites, which is why I won't explain it here. You can of course also for example take a question mark (?), but this is unnecessary, actually not intended for it and can cause problems depending on the program.
Here is a short list of common hyperlinks:
Points to the root page
Link
Points to a file relative to the root page
Link
Points to a file relative to the current file
Link
Points to a file in the previous folder
Link
Points to a file in the second previous folder
Link
Points to a file in a folder below
Link
Points to the current file
Link
Points to a page with a different host but the same protocol
Link
I hope that my answer will help some people, because I found it via a search engine and saw that there is no correct answer. And it's my first answer here 😅
If you want it to go nowhere, you can use
link
But if you want it to reload the page, you'll have to go with JavaScript.
If you want to reload the page you could use the Meta refresh tag
http://www.w3.org/TR/WCAG20-TECHS/H76.html
If you want to reload the page, you really should take a look into javascript. It is the best way to do it.
Just do this:
This Very Site
Source: I saw this in the source code of Matthew Alger's website. Check it out for yourself!
Why not try ?
I looked some things up, and as it turns out, ./ refers to current directory.
You can just make a link to the same page.
Here ya go. Hope this is what you are looking for
Link

Is it possible to make a link from my website go to the middle of the page on an outside website?

I am attempting to link from my website to an outside website but the information that relates to the user is in the middle of the outside page. Can I make the link take them to there?
Thank you in advance
If that outside page has an anchor tag in or near the content you wish to link to, yes.
<a name="releventContent">
If the above code (or something like it) is present in the outside page, you can link to it from your site like so:
clicky
I can suggest you a dirty trick that might work or not too. Steps
Open the new link in an IFrame.
Create a javascript function that will accept the string to search as parameter.
On the bodyload call that function that will search for the text in the source file.
Some SO links
Filling an IFRAME with dynamic content from JavaScript
Read IFrame content using JavaScript

Hiding links from Google?

Say I don't want Google to follow my links, or even notice them as links, will simply replacing the a href with an onclick location suffice?
Does Google still treat onclick location as a link? Or do they ignore it?
rel="nofollow" will do it. Google treats that right and won´t follow the link. But noticing isn´t suppressed with that solution. Perhaps don´t post it as a link... even JS will do a good job I think.
rel="nofollow" will prevent google from using it in their pagerank algorithm, but won't prevent them from following the link. To prevent them from accessing content on your site you should use robots.txt.