HTML to open url stored in a variable

Asked

Viewed 167 times

2

I don’t have much knowledge in html, I want to open a link that is stored in a variable but unsuccessfully.

<div class="csgo-item--inspectLink">
      <img src="static/img/inspect.png" href="{{item.inspect}}" target="_blank"style="width:16px;">
</div>

the link is in the variable item.Inspect if I put to show what is inside the variable it shows the right link but do not know how to do when click on the image open the link in a new tab.

I don’t know if it’s important but here’s the css:

.csgo-item--inspectLink{
 position: absolute;
top: 5px; left: 5px;

padding: 1px 3px;
z-index: 2;

}

2 answers

1

In this case you should use the tag <a></a> with the attribute href as follows:

<div class="csgo-item--inspectLink">
      <a href="{{item.inspect}}"><img src="static/img/inspect.png" href="" target="_blank"style="width:16px;"></a>
</div>

href is not a tag attribute <img> but of the tag to click here for more information

0

The correct way is to use the link tag first and then put the image inside. So:

  <a href="{{item.inspect}}"><img src="static/img/inspect.png" target="_blank"style="width:16px;"></a>
  • when I do this it opens this link:http://localhost:8080/%7B%7Bitem.Inspect%7D%7D

  • Could send the declaration of this variable ?

  • the variable comes from a module like this: { "appid": 730, "item_type": { "name": "Weapon" }, "Inspect": "Steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198103002114A12585917845D643239943037245", }

  • in case I want only the link: Steam://rungame/730/76561202255233023/+csgo_econ_action_pre view%20S765611981030 02114A12585917845D64 323950943037245 in the case then item.

  • Could send an excerpt ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.