如何加载一个英语网站的形象,如果西班牙现场图像不存在 [英] how to load an english-site image, if the spanish-site-image does not exist
本文介绍了如何加载一个英语网站的形象,如果西班牙现场图像不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个多语言网站。与HTML,JavaScript的,可能是阿贾克斯如果图像没有在西班牙语文件夹中存在,它应该由英文文件夹加载图像。
I have a multiple language site. With html, javascript, may be ajax if an image does not exist in spanish folder, it should load image from the english folder.
路径的例子 英文网站:图片/ home.jpg 西班牙网站:ES /图片/ home.jpg
path example english site : images/home.jpg spanish site : es/images/home.jpg
今天我message.properties ......东西做文本转换 message.properties message_es.properties
Today i have message.properties ... stuff for doing text conversion message.properties message_es.properties
推荐答案
您可以使用的onerror用于图像
You can use onerror for the image
<img src="es/images/home.jpg" onerror="this.src='images/home.jpg'">
但是,恕我直言,这是更好地做这项工作在服务器端
but, IMHO, it is better to do the job on server side
这篇关于如何加载一个英语网站的形象,如果西班牙现场图像不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文