如果西班牙语网站图像不存在,如何加载英语网站图像

问题描述 投票:0回答:1

我有一个多语言网站。使用html,javascript,如果图像不存在于西班牙语文件夹中,则可能是ajax,它应该从英语文件夹中加载图像。

路径示例 英文网站:images/home.jpg 西班牙网站:es/images/home.jpg

今天我有 message.properties ...用于进行文本转换的东西 消息属性 message_es.properties

javascript html ajax image
1个回答
4
投票

您可以对图像使用onerror

<img src="es/images/home.jpg" onerror="this.src='images/home.jpg'">

但是,恕我直言,最好在服务器端完成这项工作

© www.soinside.com 2019 - 2024. All rights reserved.