Answer the question
In order to leave comments, you need to log in
How to replace link part with html css js?
It is required to make an input
line into which a specific link (any) fits, for example :
" https://htmlforum.org/forum/123 " //htmlforum.org/forum/123 "
It became
" https://123htmlsuper.ru/forum/123 "
That is, not just from org to ru, but completely from https to a slash before org
With any link, not just this one , there is one solution, but ran into an error.
<input id="input" type="text" value="https://htmlforum.io/topic/63758-zamena-teksta-na-html-css-js/">
<br>
<button id="button">Update URL</button>
<br>
<div id="result"></div>
document.getElementById("button").addEventListener("click", function() {
var input = document.getElementById('input');
var result = document.getElementById('result');
var url = input.value;
var index = url.search(/[\/\/]\w*.(\/)/gm);
var newDomain = "https://html.com";
var newUrl = newDomain + url.substr(index);
result.innerText = newUrl;
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question