我有一个网站,我希望它适合 html img 标签,以便 img 标签正常工作。
例如,左括号 img src = "https://api.thecatapi.com/v1/images/search?format=src "右括号将为您提供一张猫的图片。
我尝试通过创建一个网站来执行类似的操作,该网站使用 window.location.replace 函数重定向另一个托管列表中一张图片的网站,但是,将我的网站插入 src 并不能解决问题。
我可以使用哪些函数/代码来允许在 img 标签中使用我的 url?
最佳答案
如果您想嵌入链接到图像(可点击图像):
<a href="google.com">
<img src="myImage.png" style="width:42px;height:42px;border:0;">
</a>
如果你想显示链接中的图像
<img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="W3Schools.com">
此处解释:https://www.w3schools.com/html/html_images.asp
如果您想在新选项卡中打开图像
<a href="www.google.com" target="_blank">
<img width="250" height="250" border="0" align="center" src=""/> //image to show in the new window
</a>
关于javascript - 如何将 url 放入 img 标签 (html) 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58471023/