5

我实施了上传的图像显示在网站上。对于未正确上传的图像意味着我替换了错误图像?当我加载网站时,我遇到了这个问题error image not define,并且灯箱同时加载了 chrome 和 firefox,但它没有加载到 IE 中,只显示黑色背景。这是我用于显示错误图像和从网络服务上传图像的代码。

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>

功能是:

  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();
    }
4

1 回答 1

1

最后我解决了我的问题,我让灯箱在 IE 7 和 IE 8 上都可以工作,

我包括脚本文件 google api http://www.google.com/jsapi和 google.load("jquery", "1"); google.load("jquery", "1");

在 Header.php 这是与我的 lighbox.js 文件和其他库文件冲突的问题,然后我删除了该脚本并添加了新的脚本 Js 库https://ajax.googleapis.com/ajax/libs/jquery/1.8。 1/jquery.min.js

我将所有脚本 $ 符号更改为 jQuery 现在我使灯箱在 IE 浏览器和所有浏览器中都能正常工作

于 2012-12-14T14:16:33.973 回答