如何组合页面网址和JavaScript?

时间:2021-03-05 15:23:10

I have link that need url of the page, how to get the page url then insert in the link url with JavaScript?

我有链接需要页面的URL,如何获取页面URL然后插入链接URL与JavaScript?

For example, if the page url is http://example.com/blabla/blablabla/bla/

例如,如果页面网址是http://example.com/blabla/blablabla/bla/

and i don't know how to make JavaScript that combine page url and JavaScript.

我不知道如何制作组合网页网址和JavaScript的JavaScript。

<a href="http://link.cut/abc=<script>window.location.href</script>" rel="nofollow">GoToLink</a>

to link like this

像这样链接

<a href="http://link.cut/abc=http://example.com/blabla/blablabla/bla/">GoToLink</a>


<a href="http://link.cut/abc=http://example.com/blabla/blablabla/bla/">GoToLink</a>

1 个解决方案

#1


give it an ID then manipulate throw javascript

给它一个ID然后操纵抛出javascript

<a id="a1" href="#" rel="nofollow">GoToLink</a>

<script>
document.getElementById("a1").href="http://link.cu/abc="+window.location.href; 

</script>

#1


give it an ID then manipulate throw javascript

给它一个ID然后操纵抛出javascript

<a id="a1" href="#" rel="nofollow">GoToLink</a>

<script>
document.getElementById("a1").href="http://link.cu/abc="+window.location.href; 

</script>