0
在JavaScript中,我想在未找到原始圖像時顯示默認圖像。我很確定我錯過了一些小事,但仍然無法弄清楚它是什麼。 http://jsfiddle.net/yfm6E/當原始圖像未找到時顯示圖像
objImg = new Image();
objImg.src = 'http://tiltips.com/wp-content/uploads/2013/02/imgurlogo.jpeg';
if(!objImg.complete)
{
// alert('no');
src = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQGdkmZ9a8Kk-AX1W3wGWZeXnp2OdbSAzqiWnstiFJGg-ZI04Yc'; //load other image
}else{
// alert('yes');
src= 'http://tiltips.com/wp-content/uploads/2013/02/imgurlogo.jpeg';
}
var layout = Ext.create('Ext.panel.Panel', {
//renderTo: 'layout',
width: 300,
height: 300,
title: 'My Panel', //no title will be blank
html: "<img src= src width='120' height='150'/> ",
renderTo: Ext.getBody() //get the body and display Layout at there
});
太謝謝你了! – Noon 2013-04-28 16:57:51