S
S
snake_jan2017-12-18 16:03:11
PHP
snake_jan, 2017-12-18 16:03:11

How to substitute a protocol for all links on a page?

Hello, please help.
There is a page, all links on it are OUTGOING, that is, to other sites.
If you write LINK , then the browser interpreter considers it a subfolder of the site. Is it
possible, with a small script, to add the protocol automatically to all hrefs, at least two slashes at the beginning?
I've looked all over the internet and it looks like this hasn't happened before. I really look forward to your help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2017-12-18
@Minifets

Under jQuery:

$('a').each(function () {
        let $this = $(this);
        $this.attr('href', 'http://' + $this.attr('href'));
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question