如何显示从 json 到 html 的超链接
how to show up an hyperlink into html from json
我有这个json:
tipo={
"type":"FeatureCollection",
"crs":{
"type":"name",
"properties":{
"name":"urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features":[
{
"type":"Feature",
"properties":{
"pic":"./p2.png",
"nombre":"T2V",
"web":"www.t2v.com"
},
"geometry":{
"type":"Point",
"coordinates":[
-4.45497,
36.692029
]
}
},
{
"type":"Feature",
"properties":{
"pic":"./p2.png",
"nombre":"NETBLUE",
"web":"www.netblue.es"
},
"geometry":{
"type":"Point",
"coordinates":[
-4.427596,
36.713663
]
}
},
]
}
我需要使用以下代码在 html 的弹出窗口中显示每个字段的超链接:
`
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;
};
info.update = function (props) {
// console.log(props);
this._div.innerHTML = ''
+(props? '<br><img src="'+props.pic+'"style="height:75px; display: block;margin-left: auto;margin-right: auto;">': '')
+(props? '<b><center style="color:#838383; margin-top:10px;">'+props.nombre+'</center></b>': '')
+(props? '<br><b><center style="color:#838383"><a href>'+props.web+'</a></center></b>': '');
this._div.innerHTML += '<br /><img src="link.png" style="background:#FFC627; margin-left:20px; margin-right:15px; margin-top:0px">';
};
info.addTo(map);`
但问题是超链接显示在带有典型下划线的弹出窗口中,但是当我点击超链接时,网页只刷新,它不会转到 json 的相应网页.
'<a href>'+props.web+'</a>'
不是 link 的工作方式(事实上,它是无效的 HTML)
href
属性应包含 link 的地址作为值。
'<a href="' + props.web + '">I am a working link</a>'
请查看 documentation 以了解有关 <a></a>
标签的更多信息。
我最后一句话可以HTML这样写
<p>
Please take a look at the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a">documentation</a> for more informations about the <code><a></a></code> tag.
</p>
我有这个json:
tipo={
"type":"FeatureCollection",
"crs":{
"type":"name",
"properties":{
"name":"urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features":[
{
"type":"Feature",
"properties":{
"pic":"./p2.png",
"nombre":"T2V",
"web":"www.t2v.com"
},
"geometry":{
"type":"Point",
"coordinates":[
-4.45497,
36.692029
]
}
},
{
"type":"Feature",
"properties":{
"pic":"./p2.png",
"nombre":"NETBLUE",
"web":"www.netblue.es"
},
"geometry":{
"type":"Point",
"coordinates":[
-4.427596,
36.713663
]
}
},
]
}
我需要使用以下代码在 html 的弹出窗口中显示每个字段的超链接: `
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;
};
info.update = function (props) {
// console.log(props);
this._div.innerHTML = ''
+(props? '<br><img src="'+props.pic+'"style="height:75px; display: block;margin-left: auto;margin-right: auto;">': '')
+(props? '<b><center style="color:#838383; margin-top:10px;">'+props.nombre+'</center></b>': '')
+(props? '<br><b><center style="color:#838383"><a href>'+props.web+'</a></center></b>': '');
this._div.innerHTML += '<br /><img src="link.png" style="background:#FFC627; margin-left:20px; margin-right:15px; margin-top:0px">';
};
info.addTo(map);`
但问题是超链接显示在带有典型下划线的弹出窗口中,但是当我点击超链接时,网页只刷新,它不会转到 json 的相应网页.
'<a href>'+props.web+'</a>'
不是 link 的工作方式(事实上,它是无效的 HTML)
href
属性应包含 link 的地址作为值。
'<a href="' + props.web + '">I am a working link</a>'
请查看 documentation 以了解有关 <a></a>
标签的更多信息。
我最后一句话可以HTML这样写
<p>
Please take a look at the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a">documentation</a> for more informations about the <code><a></a></code> tag.
</p>