【发布时间】:2019-03-08 14:09:12
【问题描述】:
在我的 html 代码中,我使用了 <a> 标记和空的 <href>,因为开头的 URL 是未知的。
假设现在的新目标是“www.amazon.de”。 现在我尝试用javascript更改href:
document.getElementById('linkname').setAttribute("href", "www.amazon.de");
但我的浏览器只创建一个指向我的域的相对链接,如下所示:
https://www.mydomain.de/www.amazon.de>
(如果我将鼠标悬停在链接上,则会显示)
【问题讨论】:
标签: javascript href absolute-path setattribute