X
X
xamer202022-03-30 16:08:10
HTML
xamer20, 2022-03-30 16:08:10

How to make a custom link?

Hello! There is a need to create a custom link, but after browsing the Internet, I only come across services for shortening links, this does not suit me. I will give an example of what I need. Let's say I have a link https://siterule2352.news/hot-blog/news-rock, and I need to create a link similar to this one, but so that it already throws to my site. I must say right away that I do not need a redirect, I will insert the link into the site in the tag <a>. The most important thing is that the user pointing at the link sees it similar to the one that should be. Can someone tell me a service or a way that will help me implement this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
n1ksON, 2022-03-30
@xamer20

Hang an event handler on the link tag and cancel the action of the link by redirecting via JS
HTML: JS:
<a href="https://example.com">link</a>

document.querySelector('a').addEventListener('click', (e) => {
  e.preventDefault()
  window.open('https://anotherLink.com')
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question