M
M
m3252015-10-07 13:57:54
HTML
m325, 2015-10-07 13:57:54

Html how to pass macro to js?

It is necessary to substitute links in %link1% via js.
The markup itself:
<a href="%link1%>link</a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivanq, 2015-10-07
@Ivanq

Can

var link1 = "http://yandex.ru";
for(var i=0;i<document.links.length;i++) {
    var a = document.links[i];
    if(a.href == "%link1%") a.href = link1;
}

But this is a bad decision. It's much better to replace links in a server-side language - PHP or Perl

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question