How to remove #name from URL? - html

I have a site which has a inner hyperlink http://www.example.com/#name. I want to change it to http://www.example.com.

If it's just in HTML, you need to just simply stop linking to #name and link to the root instead. Go through all your anchor links and remove the reference to #name.
If you have access to dynamic server side languages, you can dynamically filter the content based on a cookie/session/querystring thus removing the need for named anchors.

your question is similar to this stackoverflow.com post:
jQuery removing hash value from URL

java: url.substring(0, url.indexOf("#"));

Related

How to use the MT:EntryBody tag with additional modifiers for removing content

I'm trying to remove text (with a specific class) from MT:EntryBody. More specifically, I'm trying to remove headers from my summary pages.
On this page, http://www.taconic.com/taconic-insights/microbiome-and-germ-free/, in the middle of the first entry there is text that says "Defining Rodent Health Standards". This makes no sense in the summary (because I'm stripping HTML - obviously). SO I want to just remove this line from the summary. I tried using a tag as well as a CSS hidden class but I can't get this to work properly.
Thoughts?
To clarify, you want to remove this in the entry body?
<h3 class="hidden">Defining Rodent Health Standards</h3>
Then, before stripping HTML, you need to use a regexp to catch and remove those blocs. Then, you can remove HTML.
See https://movabletype.org/documentation/appendices/modifiers/regex-replace.html
The easiest thing you could do is to replace:
<$mt:EntryBody$>
With:
<$mt:EntryBody replace="Defining Rodent Health Standards",""$>
Glad to answer also other questions that you might have!

CSS Substring display none

Is it possible in CSS (only) to hide some text of a string?
I know there these attribute-selectores like:
[att^=val] – the “begins with” selector
But for instance, having this:
<div class="some_random_text">
This is a default text
</div>
I want to (display: none) only a certain substring - in thise case "default". I know how to do it with JS, but I'm looking for a CSS-solution only (if there is any).
Even though I guess it isn't possible to manipulate the DOM via CSS, which would be neccessary to have something like:
this is a <span class="hideThis">default</span> text
why would you need this and where does it occur?
For instance in a CMS (in my case OXID). You can add a title to a specific payment-method. Here I have
paypal
paypal (provider1)
paypal (another dude)
I want to have only PayPal visible in the frontend. The other PayPal-Paymenttypes have to remain however. Naming them all PayPal just leads to confusion.
there is the content-property. Is it somehow managable with that?
Again, no JS :-)
To answer your question - no, it's not possible using only CSS.
You can;
Edit the HTML as you suggested
this is a <.span class="hideThis">default<.span > text
Use JS to alter the elements innerHTML value
Use a pre-processing language (like PHP or ASP, whatever you are able to use) to reduce the string to a substring.
Sorry if that's not the answer you wanted, but those are your options.
It it not possible. The only thing that can actually modify the inside text is the content property. Assuming something changes in your dom, you can have rules like:
.some_random_text:after {
content: "This is a text";
}
other_select .some_random_text:after {
content: "This is a default text";
}
But sincerely, I don't get the point, as JS and consors are made for that.
It's not possible, here's the documentation on selectors: https://www.w3.org/TR/css3-selectors/#selectors

Set an anchor element's href relative to the current URI?

Im on the page:
example.com/news
It's a list of news articles. Is it possible to set links on each news article and take into account the current url?
link to something
The above will link to:
example.com/news/article
Or will I need to get the entire route and specify that in the link?
The url could be anything eg. /products so I do not want to hardcode it in.
If you need to take into account the current path, use the page name directly in the href attribute:
If you are on example.com/news and used an href value of "article", the URL becomes example.com/news/article.
If you need to reference pages on the root directory, precede the page name with slash '/', href="/article".
Make it relative?
link to something
For some browsers/DOCTYPE, you may have to use this in conjunction with the base tag element, which will need to be added to every page that utilises relative paths:
<base href="http://www.example.com/news">

Can disable or comment inside value of href in anchor tag?

My problem is i wanna have some comment or disable some text inside value of href attribute of anchor tag.
I mean look like this:
Jquery.com
And when i click url redirect to stackoverflow.com and behave with domain.com like a comment or don't have any effect to link. Value in square bracket just like a comment inside url :[domain.com]
Can i do this without using jquery or javascript just like // or /**/ for normal comment inside code.
Please help me and thanks for reading.
Comments in HTML are this way :
<!-- [domain.com] -->
but that won't work in your case.
Why do you need to leave the [domain.com] if you want it to be effectless ?
Anyway, you could do something like that :
Jquery.com
and JS:
$('a.linkWithComment').click(function(e) {
$(this).attr('href', $(this).attr('href').replace(/\[(.*)\]/g,''));
});
Here's a JSFiddle for it : http://jsfiddle.net/kJDUB/
BUT be aware that this is absolutely not a recommended behaviour: SEO is probably broken, and there a many solutions to achieve same behaviour while being cleaner (like HTML5 tags : Jquery.com
and you can still reach the domain.com ...)

A relative url value for href attribute [duplicate]

This question already has answers here:
How do I reload the page without the query parameters?
(14 answers)
Closed 9 years ago.
Let's say currently I'm at www.example.com/category1/?page2, I want to put an anchor tag in the html which could redirect me to www.example.com/category1. I tried to use href='/' but it will take me to www.example.com instead of www.example.com/category1. I also tried to use href=" " but it just refresh the current page. So how should I specify the href attribute of the anchor tag?
One thing you should consider when writing relative URLs is the use of a base element. Base elements allow you to define the the context for a relative URL path.
Information about using the base element: Click Here
if you use a relative url, it's always relative to the top level, not whatever level you're at. So if you want to be at www.example.com/category1, use /category1
EDIT: misunderstood your question. If you want to just clear get params from your url, look at similar questions like How do I reload the page without the query parameters? (looks like using window.pathname is the cleanest solution)
You can use href="../category1/"
As has been noted, if you know the pathname and want to hardcode it into the markup, you can just specify the relative path:
<a title="Go to Category 1" href="/category1">Category 1</a>
Otherwise, if you want a dynamic solution or don't want to hardcode the path, you can use javascript to get rid of the query parameters and make clicking the link do a redirect:
Category N
(For more information on window.location and its properties, see https://developer.mozilla.org/en-US/docs/DOM/window.location#Properties .)