Jestem zaimplementowany załadowane obrazy są wyświetlane na stronie. W przypadku obraz niepoprawnie załadowany oznacza, że zastępuję obraz błędu na , który? Po załadowaniu strony napotykam problem error image not define
, a dla lightbox jest ładowany zarówno w chrorze, jak i Firefoxie , ale nie ładuje się go w IE, wyświetlając tylko czarne tło. Oto mój kod do wyświetlania obrazu błędu i przesyłania obrazu ze stron internetowych.Wobec problemu wymaganego obiektu problemu błąd w IE 8 i lightbox nie działa w IE 8 i IE 7 sam
kod PHP:
foreach(object_2_array($ans->answerDocumentList) as $document){
if ($document->documentHttpUrl!= ''):
$document_name_explode = explode('.',$document->documentName);
$file_type = trim($document_name_explode[1]);?>
<div class="documentation_class" <?php if($k%2==0){?> style="float:none;margin-left:0px;" <?php }else{ ?> style="float:left;"<?php } ?>>
<?php if(($file_type!="") &&($file_type=="png" || $file_type=="jpg" || $file_type=="jpeg" || $file_type=="gif")){ ?>
<a rel="lightbox[document]" href="<?php echo stripcslashes($document->documentHttpUrl); ?>">
<img alt="<?php echo stripcslashes($document->documentName); ?>" src="<?php echo APP_FORUM_URL;?>/images/ajax-load.gif" dataimage="<?php echo stripcslashes($document->documentHttpUrl); ?>" class="document_image" style="max-width:644px !important;" onerror='errorImage("<?php echo RESOURCE_URL_BASE;?>",this);' border="0" />
</a>
<br/>
<?php } else{
echo $document->documentName;
} ?>
<div class="question_float_left download_link">
<a href="<?php echo stripcslashes($document->documentHttpUrl); ?>">Click here to download this file</a>
</div>
<?php endif; ?>
<input type="hidden" value="<?php echo $document->documentId; ?>" class="list_document_id"/>
<input type="hidden" value="<?php echo $document->documentName; ?>" class="list_document_title"/>
</div>
<?php $k++; }?>
<script>
funkcji jest następująca:
function errorImage(url,ctrl){
ctrl.style.border='solid 1px black';
ctrl.src='<?php echo APP_FORUM_URL; ?>images/broken-image.jpg';
$(ctrl).parent().parent().find('.download_link').hide();
}
Używasz tutaj 'stripcslashes' w bardzo, bardzo dziwny sposób. To, i jego kuzyni 'addslashes' i' stripslashes' to * zapach kodu *. Często są nadużywane tam, gdzie należy ucieczka bazy danych, ale ten przypadek jest po prostu * dziwny *. Robią * nic * dla ciebie tutaj. Spodziewam się, że naprawdę zamierzałeś użyć ['htmlspecialchars'] (http://php.net/htmlspecialchars), ponieważ byłoby to słuszne w kontekście. – Charles