Answer the question
In order to leave comments, you need to log in
How to make a condition based on the search result in the current URL?
Good day.
I am making a curved version of the site in two languages. And this option suits me in the constructor.
But in one place of the constructor, the built-in function doesn't work. I know it's not difficult to do this in JS, but I don't know how.
The question is very urgent .... Today, to hand over the site, but one page does not lend itself.
The principle is this
There is a site "URL"
We are looking for "?lang_ee" at the end of the URL.
If it is, write the text АААААААААААА
If it is not present, write the text BBBBBBBBBBBBBBB
Thank you
Answer the question
In order to leave comments, you need to log in
let params = new URLSearchParams(location.search);
if(params.has(`lang__ee`)){
document.querySelector(`selector`).textContent = `Some Text`.
}else{
document.querySelector(`selector`).textContent = `Other Text`.
}
selector
replace with a valid selector of an existing element in which you want to output a message.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question