How to use JavaScript variable in an HTML link

后端 未结 4 1793
面向向阳花
面向向阳花 2021-01-27 22:18

The website that I am working on has a tag point to a different URL than the one that the website has. What I would like to do is get around the

4条回答
  •  一整个雨季
    2021-01-27 22:45

    If you are serious about trueURL = window.location.href then you are working WAY too hard.

    Just make the link #link1 - it automatically will be relative to the current href.

    If that was just an example, you may be interested in the:

    
    

    tag. This will let you change the relative href for all links in the page at once.

    And you can do it with javascript by getting each DOM element and modifying the href property.

提交回复
热议问题