Tôi đang triển khai hình ảnh được tải lên được hiển thị trên trang web. Đối với hình ảnh không được tải lên chính xác có nghĩa là tôi thay thế hình ảnh lỗi trên ? Khi tôi tải trang web, tôi đang gặp vấn đề error image not define
và hộp đèn đang tải ở cả chrome và firefox nhưng không tải trong IE, chỉ hiển thị nền đen. Đây là mã của tôi để hiển thị hình ảnh lỗi và tải lên hình ảnh từ các dịch vụ web.Đối mặt với một vấn đề đối tượng yêu cầu lỗi trong IE 8 và hộp đèn không hoạt động trong IE 8 và IE 7 một mình
Mã 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>
Chức năng là:
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();
}
Bạn đang sử dụng 'stripcslashes' ở đây theo một cách rất, rất kỳ quặc. Nó, và những người anh em họ của nó 'additionallashes' và' stripslashes' là một * mã mùi *. Chúng thường bị lạm dụng khi cơ sở dữ liệu thoát ra, nhưng trường hợp này chỉ là * lạ *. Họ đang làm * không có gì * cho bạn ở đây. Tôi hy vọng rằng bạn thực sự muốn sử dụng ['htmlspecialchars'] (http://php.net/htmlspecialchars), vì đó sẽ là điều thích hợp để sử dụng trong ngữ cảnh. – Charles