a链接包含图片,点击图片不放大直接跳转到a链接地址

This commit is contained in:
caishi 2023-07-20 18:46:43 +08:00
parent b04fbbd976
commit d6df119fd2
2 changed files with 19 additions and 18 deletions

View File

@ -73,11 +73,7 @@
window.location.hash = $(this).attr("name");
return false;
});
}
// window.addEventListener("popstate", function(e) {
// console.log("popstate",e);
// history.go(-2);
// }, false);
}
</script>
</body>

View File

@ -16,20 +16,25 @@ export function ImageLayerOfCommentHOC(options = {}) {
onDelegateClick = (event) => {
const imageSrc = event.target.src || event.target.getAttribute('src') || event.target.getAttribute('href')
// 判断imageSrc是否是图片
const fileName = event.target.innerHTML.trim()
if (isImageExtension(imageSrc.trim()) || isImageExtension(fileName) || event.target.tagName == 'IMG') {
// 非回复里的头像图片; 非emoticons
if (imageSrc.indexOf('/images/avatars/User') === -1 &&
imageSrc.indexOf('kindeditor/plugins/emoticons') === -1) {
this.setState({
showImage: true,
imageSrc,
})
const fileName = event.target.innerHTML.trim();
const parentNodeUrl = event.target.parentNode && event.target.parentNode.getAttribute('href');
if(parentNodeUrl){
window.location.href = parentNodeUrl;
}else{
if (isImageExtension(imageSrc.trim()) || isImageExtension(fileName) || event.target.tagName == 'IMG') {
// 非回复里的头像图片; 非emoticons
if (imageSrc.indexOf('/images/avatars/User') === -1 &&
imageSrc.indexOf('kindeditor/plugins/emoticons') === -1) {
this.setState({
showImage: true,
imageSrc,
})
}
event.stopPropagation()
event.preventDefault && event.preventDefault()
event.originalEvent.preventDefault()
return false;
}
event.stopPropagation()
event.preventDefault && event.preventDefault()
event.originalEvent.preventDefault()
return false;
}
}